Jump to content


Photo

Basic Js To Force Open New Window With Size


  • Please log in to reply
5 replies to this topic

#1 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 30 November 2012 - 08:01 AM

Hi I'm using a little js to open a specified sized new window on my webpage. It works fine in firefox and chrome but doesn't work in IE 8. An error code in Ie says "invalid argument". Is there a away around this or a better way to do it?

<a href="#" onclick="window.open('feeds.html', 'RSS Feed List', 'width=800, height=800')"> <img src="images/rss.jpg" width="32" height="32"/></a>

Thank you :)

#2 Adam

Adam

    Advanced Member

  • Gurus
  • 5,680 posts
  • LocationSheffield / UK

Posted 30 November 2012 - 08:39 AM

Can't spot anything wrong with it. Is the error definitely coming from that line?

#3 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 30 November 2012 - 10:15 AM

Well in IE error it points to character 1 of this line:
<td width="17%" align="right" valign="middle"><img src="images/fbbadge.jpg" width="32" height="32" /> <img src="images/twitterbadge.jpg" width="32" height="32" /> <a href="#" onclick="window.open('feeds.html', 'RSS Feed List', 'width=800, height=800')"> <img src="images/rss.jpg" width="32" height="32"/></a></td>
This isnt even the line of code the js is on.

Thank you

#4 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 30 November 2012 - 10:20 AM

I have noticed that # appears in url after index.php after clicking. If i remove the # out of the
<a href="#" onclick="window.open('feeds.html', 'RSS Feed List', 'width=800, height=800')">

There is not error but it still doesnt open a new window in IE. Its strange because it all works just fine in FF and Chrome. I cant put feeds.html within the hyperlink because it will just go to that page in the current window.

#5 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,568 posts
  • LocationBonita, FL

Posted 30 November 2012 - 03:36 PM

The name parameter should not contain any spaces or special characters.   
window.open('feeds.html', 'rssfeed', 'width=800,height=800')

Also, this would be a better way of coding it which will allow the link to work still even if JS is disabled:
<a href="feeds.html" onclick="return !window.open(this.href, 'rssfeed', 'width=800,height=800')">

Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#6 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 02 December 2012 - 04:31 AM

Thank you very much thats works a treat! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com