2015-10-15 94 views
-1

这可能听起来像一个愚蠢的问题,但那是因为它。是否有这样的理由不会真正对页面提出要求?我点击它,没有任何反应。Javascript will not href to another page

window.location.href = "http://theromdepot.com/roms/report.php?file=" + window.location.pathname + "/" + document.getElementById('title').innerHTML + "&issue=" + issue; 

我实际上做了另一个网站,功能基本上相同的方式,它工作得很好。此代码是别的东西,但它本质上发送信息,以同样的方式:

window.location.href = "rename.php?originalname=" + originalname + "&newname=" + newname; 

有事情,因为我实际复制并从其他网站做的工作粘贴代码和我有同样的问题,一些奇怪的事情。我点击按钮,没有任何反应。我在href之前和之后发出警报,以确保函数被调用,并且只是没有页面更改。不知道PHP是否以任何方式参与。有人能告诉我这里发生了什么事吗?

下面是完整的页面:http://pastebin.com/zHfHcYmV

这里的网站,以防万一:http://theromdepot.com/

回答

3

在您的网页,这行代码:

window.location.href = "http://theromdepot.com/roms/report.php?file=" + window.location.pathname + "/" + document.getElementById('title').innerHTML + "&issue=" + issue 

抛出这个错误,因此不会成功执行:

Uncaught TypeError: Cannot read property 'innerHTML' of null 

This大概是因为document.getElementById('title')返回null,因为您的HTML中没有元素与id="title"

+0

哇,我真的应该看起来更难。非常感谢你。 – Syllith

+0

@Syllith - 是的。无论何时,按预期方式工作不正常,请始终查看错误或调试日志。你的第一个线索经常在那里。 – jfriend00