Search code examples
javascriptinternet-explorer.htaccessurlwindow.open

Javascript Window.open wrong URL in IE


have a a problem with opening a new window using javascript. In Chrome and Firefox this works great but IE gives wrong url.

The link is located on a page like this: www.CORRECTURL.com/SEOKEYWORD/SONGID/SONGNAME.html

The link:

<a href="javascript:void(0)" onclick="window.open('extraListen.php?visa=<?php echo($songID); ?>','welcome','toolbars=1, scrollbars=1, location=1, statusbars=1, menubars=1, resizable=1, width=748, height=660, left = 300, top = 100')">Listen</a>

In chrome/firefox this opens: http://www.CORRECTURL.com/extraListen.php?visa=19 In IE this opens: http://www.CORRECTURL.com/SEOKEYWORD/SONGID/extraListen.php?visa=19

When the "seokeyword" and "songid" is added to the link, the new page cant be found, but I dons understand how IE can just add this in the url and chrome, firefox doesn't!??

BTW I have the following htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteRule midsommarvisor/(.*)/(.*)\.html$ index.php?visa=$1&midsommarvisa=$2 [L]
RewriteRule sitemap\.xml sitemap.php [L]
RewriteRule rss\.xml rss.php [L]
RewriteRule (.*)/(.*)\.html$ index.php?fel=$1&page=$2 [L]
RewriteRule (.*)\.html$ index.php?page=$1

I don't know where to start...


Solution

  • As I touched upon on my comment. I believe that the problem here is with your url not starting with a forward slash /. Try the following in your onclick event:

    onclick="window.open('/extraListen.php?visa=<?php echo($songID); ?>'
    

    the problem is that without the slash at the start, some browsers do not recognise it as a root path URL and will therefore try to append it to the current request path, as opposed to appending it to the domain name only.