开发者

Targeting JS named opening window in Safari?

开发者 https://www.devze.com 2022-12-10 12:16 出处:网络
I have a static HTML page which is named via JavaScript as such: window.name = "windowname". This window opens a popup window, which contains links that target windowname.

I have a static HTML page which is named via JavaScript as such: window.name = "windowname". This window opens a popup window, which contains links that target windowname.

This works as expected in IE/FF/Chrome and opens the links on the opener, however, Safari opens all links in a new window and not the opener.

Is anyone aware of a workaround or solution to this other than using JavaScript to open the links via opener.location.href? Is this a security feature of Safari or some other kind of issue?

T开发者_运维百科hanks in advance


Trying setting the "id" attribute to the same string as the name.


Not 100% sure what you problem is without being able to see your code but the following worked for me in Safari 4:

windowname:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>untitled</title>

</head>

<body onload="window.name='windowname'">
<a href="#" onclick="window.open('popup.html')">Open</a>

</body>
</html>

popup:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>untitled</title>

</head>

<body>
<a href="http://google.com" target="windowname">test</a>
</body>
</html>


No resolution for this was ever found, I had to go with a method that didn't use pop-up windows due to this.

thanks for the effort.

b

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号