You are here: Re: Forcing a script to open a link in a new window or tab « HTML « IT news, forums, messages
Re: Forcing a script to open a link in a new window or tab

Posted by Michael Winter on 05/04/06 21:32

On 04/05/2006 18:58, Steve Pugh wrote:

> "Jeremy Brown" <jerem43@att.net> wrote:

[snip]

>> <script language="javascript" type="text/javascript"
>> src="http://ss.webring.com/navbar?f=j;y=jerem43;u=defurl">

As the code is generated by an external site, modifying the markup is
obviously out of the question. However, it is possible to alter the
target attributes after the fact:

function modifyWebringTargets() {
var ring;

if (document.getElementById
&& (ring = document.getElementById('webring'))
&& ring.getElementsByTagName) {
var links = ring.getElementsByTagName('a');

for (var i = 0; i < links.length; ++i) {
links[i].target = 'webring';
}
}
}

<div id="webring">
<script type="text/javascript"
src="http://ss.webring.com/navba?f=j;y=jerem43;u=defurl">
</script>
</div>

Call the function above after the document's loaded and the links should
be sent to a new window.

[snip]

>> function SymError()
>> {
>> return true;
>> }
>>
>> window.onerror = SymError;
>>
>> var SymRealWinOpen = window.open;
>>
>> function SymWinOpen(url, name, attributes)
>> {
>> return (new Object());
>> }
>>
>> window.open = SymWinOpen;

[snip]

> That looks like it opens in a new window anyway (window.open being a
> bit of a clue).

Quite the opposite, actually. That's pop-up blocker code injected by a
Symantec product (though I don't know why it's in the markup, in this case).

If you care to take another look, notice that the open property is being
assigned a reference to a new function, SymWinOpen. All this function
does is return an object to make it look like the call succeeded.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация