Internet Explorer Incompatibility - page just shows “[object Object]” WTH?

元气小坏坏 提交于 2019-11-28 07:16:24

问题


When I click on a URL with the link "javascript:$('#dialog-modal').dialog('open');" in Chrome and FF my Jquery dialog loads. In Internet explorer 8 the page source disappears and is replaced with "[object Object]" .. WTH?


回答1:


The problem is IE8 expects you to do something with the click event. The below code works and has been tested in Firefox, chrome, IE8. Notice you need the void(0) to make it work.

   <a class="dialogBtn" href="javascript:$('#layer1').hide();void(0);" style="text-decoration:none;color:#FFF">OK</a>

Or you can use this syntax:

   <a class="dialogBtn" href="javascript:void(0);" onclick="$('#layer1').hide();" style="text-decoration:none;color:#FFF">OK</a>



回答2:


In Internet Explodezor JQuery doesnt seem to work via hyperlinks. Therefore I encapsulated this inside a function and just called the function.

Edit: Seriously whyyy do I have to wait 2 days to accept my own answer....



来源:https://stackoverflow.com/questions/5066733/internet-explorer-incompatibility-page-just-shows-object-object-wth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!