【问题标题】:Javascript Window.open wrong URL in IEJavascript Window.在 IE 中打开错误的 URL
【发布时间】:2012-05-05 05:47:10
【问题描述】:

在使用 javascript 打开新窗口时遇到问题。在 Chrome 和 Firefox 中这很好用,但是 IE 给出了错误的 url。

链接位于这样的页面上: www.CORRECTURL.com/SEOKEYWORD/SONGID/SONGNAME.html

链接:

<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>

在 chrome/firefox 中打开:http://www.CORRECTURL.com/extraListen.php?visa=19 在 IE 中打开:http://www.CORRECTURL.com/SEOKEYWORD/SONGID/extraListen.php?visa=19

在链接中添加“seokeyword”和“songid”时,无法找到新页面,但我不明白IE如何在url和chrome中添加这个,firefox没有!??

顺便说一句,我有以下 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

我不知道从哪里开始......

【问题讨论】:

  • 在您的网址可能会修复它之前放置一个正斜杠/...window.open('/extraListen.php?visa=&lt;?php echo($songID);
  • 完美!!这么简单的事情,我错过了,非常感谢!

标签: javascript internet-explorer .htaccess url window.open


【解决方案1】:

正如我谈到我的评论。我相信这里的问题在于您的网址不是以正斜杠/ 开头。在您的 onclick 活动中尝试以下操作:

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

问题在于,如果开头没有斜杠,一些浏览器不会将其识别为根路径 URL,因此会尝试将其附加到当前请求路径,而不是仅将其附加到域名。

【讨论】:

  • 哇,太棒了。非常感谢缪斯凡!节省了很多时间来解决这个问题!
  • 仅作记录,将其视为相对路径的“某些浏览器”正确遵循规范。
猜你喜欢
  • 2011-07-09
  • 1970-01-01
  • 2011-11-18
  • 1970-01-01
  • 2014-10-03
  • 2011-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多