javascript - onclick="window.open" issues in IE - Stack Overflow

I'm having a hard time getting this to work in IE. All the other browsers are working perfectly! C

I'm having a hard time getting this to work in IE. All the other browsers are working perfectly! Can't use a transparent gif because this link is being used inside a cycling background image. If I place a gif, it does not cycle anymore... Anyone suggestions?

<div onclick="window.open('mylink.html','new_window');" style="display:block; float:right; height:40px; width:100px; cursor:pointer;">

I'm having a hard time getting this to work in IE. All the other browsers are working perfectly! Can't use a transparent gif because this link is being used inside a cycling background image. If I place a gif, it does not cycle anymore... Anyone suggestions?

<div onclick="window.open('mylink.html','new_window');" style="display:block; float:right; height:40px; width:100px; cursor:pointer;">

Share Improve this question asked Mar 16, 2011 at 18:37 detonatedetonate 2893 gold badges11 silver badges21 bronze badges 4
  • sad you're not having issues in all browsers... – jondavidjohn Commented Mar 16, 2011 at 18:43
  • Describe what is happening, in detail. – Lightness Races in Orbit Commented Mar 16, 2011 at 18:43
  • what IE version are we talking about ? – thedev Commented Mar 16, 2011 at 18:50
  • I'm creating a Div container so it can look like I'm clicking on a portion of my background image. It all works well except for IE (of course). – detonate Commented Mar 16, 2011 at 18:52
Add a ment  | 

3 Answers 3

Reset to default 2

I believe IE still only fires onClick events from elements that are normally clickable.

Do this:

<a href="#" onclick="window.open('mylink.html','new_window'); return false" style="display:block; float:right; height:40px; width:100px; cursor:pointer; text-decoration:none">

(of course use the corresponding </a> instead of </div> at the end)

Not sure what a transparent gif has to do with it.

For link, I prefer use the tag <a> :

<a href="mylink.html" target="_blank" style="display:block; float:right; height:40px; width:100px; cursor:pointer;"> Your link </a>

You can even put a picture between <a> <img .... /> </a> Don't forget to add in style : text-decoration:none;

Check your IE settings to see if popups are allowed.

The click event is properly fired in IE 8

demo: http://jsfiddle/R249t/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744715025a4589566.html

相关推荐

  • javascript - onclick=&quot;window.open&quot; issues in IE - Stack Overflow

    I'm having a hard time getting this to work in IE. All the other browsers are working perfectly! C

    16小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信