|
Posted by jojo on 09/30/07 11:53
> jojo wrote:
>> crazyjxx@gmail.com schrieb:
>>> I have been trying to create my own webpage and I am wondering if there
>>> is a way to create a link on my webpage that sends the person to
>>> multiple urls in new windows. For example if they click on a link on
>>> my page "Cnn and Yahoo" it will open two seperate pages in new windows
>>> Cnn.com and yahoo.com. I have been using a html edditor to create my
>>> page so the html code to be able to do this would be greatly
>>> appreciated. Thanks alot
>>>
>>
>> Yes, it is possible, but it is not with pure HTML. You need to use
>> JavaScript here. The problem is that many users do not have JS enabled
>> for security reasons, so /they/ might not be able to use those links.
>> A possibility might be to use two links and delete one with JS and
>> modify the other. That would ensure that users with JS switched off
>> still view all linked pages.
>> To realize that you have to put the following code into the <head> of
>> your page:
>>
>> <script language="javascript" type="script/javascript">
>>
>> document.getElementById("link2").style.display="none"
>> document.getElementById("link1").innerHTML="Yahoo and CNN"
>>
>> function doubleLink(page){
>> win=window.open()
>> win.location.href=page
>> }
>>
>> </script>
>>
>>
>> Your links have to look like this:
>>
>> <a href="www.yahoo.com" target="_blank" id="link1"
>> onclick="doubleLink('www.cnn.com')">Yahoo</a>
>>
>> <a href="www.cnn.com" target="_blank" id="link2">CNN</a>
>>
>> HTH,
>
> Nice idea (where id JS is disabled you will see two links), but a couple
> of problems.
>
> 1) You cannot format the style of the links until *after* they are
> created in the document. Therefore you either have to call it in a
> script element inline *after* where the links appear in the BODY or you
> have to make an initialization function that is called on the document's
> onload event.
Oh, you're right... I always forget this... Place the <script> /foo/
</script> *after* the links instead placing it in the <head>...
> 2) the href's in links must have the protocol 'http://' else they will
> look for the URLs locally.
You're right again. Didn't recognize that I missed it.
Navigation:
[Reply to this message]
|