markzzz
markzzz

Reputation: 47945

Why this popup fail on IE?

I have this code :

<a id="bookingLink" href="javascript.void(0);">Link</a>

$('#bookingLink').click(function(e) {
    e.preventDefault();

    window.open("http://www.google.com", "Booking Daniela", "width=950,height=680");
});

and it fails (no popup is showed; also, the link in the bottom is /javascript.void(0);)

Why? And how can I fix it?

P.S. Popup are enabled on the browser :)

Upvotes: 0

Views: 216

Answers (3)

Charles Parsels
Charles Parsels

Reputation: 11

You wrote:

<a id="bookingLink" href="javascript.void(0);">Link</a>
$('#bookingLink').click(function(e) {
e.preventDefault();
window.open("http://www.google.com", "Booking Daniela", "width=950,height=680");
});

Let's rewrite this to work:

<a id="bookinglink">Link</a>

$('#bookinglink').click(function(e){
    e.preventDefault();
    window.open("http://www.google.com","Booking Daniela", "width="950,height=680");
});

If you wanted to pass the data in (e.g. if you have multiple #bookinglink elements), you could do this:

<a id="bookinglink" pagename="link1">Link</a>
<a id="bookinglink" pagename="link2">Link</a>
<a id="bookinglink" pagename="link3">Link</a>

$('#bookinglink').click(function(e){
    e.preventDefault();
    var opage = "http://www.google.com";
    var pname = $(this).attr('pagename');
    window.open(opage,pname,"width=950,height=680");
});

Upvotes: 1

alexl
alexl

Reputation: 6851

the name attribute must have no space. Try "BookingDaniela"

Upvotes: 3

Arief
Arief

Reputation: 6085

Microsoft does not support "name" attribute, so if you delete "Booking Daniela", it will work

window.open('http://www.google.com', '', 'width=950,height=680');

Check the following MS documentation page, http://msdn.microsoft.com/en-us/library/ms536651%28v=vs.85%29.aspx.

sName

"Optional. String that specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element."

Upvotes: 1

Related Questions