Html code help


#1

http://bloggersentral.blogspot.com/" target="_self" onclick="window.open("http://www.tourism.gov.my/"); window.open("http://www.tic.kelantan.gov.my/");">This anchor opens three links in a single click

i am using the above code to open three different links with one click now ineed a little help whenever i click the shortcut of above code it opens the webpages in new window i dont want then to be open in new window i want them to get open in already opend windows???

\\


#2

But how can you open three links in 1 window ?


#3

[quote=", post:, topic:"]

But how can you open three links in 1 window ?
[/quote]

Exactly :confused:


#4

I believe he wants to open three links in three tabs

of the same window.

Just replace the "_self" in your code with "_blank". I

just tried and it works like a charm.

.

.

.

Sheikh 'Coolie' Chilli


#5

i have checked the code. it opens 3 links in 3 new different tabs in firefox. your problem is related to browser and its setting. what browser are you using.


#6

sheikh_chilli's solution is correct.

"_self" tag opens page in the same window

"_blank" tag opens page in new window


#7

You need to follow some basic HTML tutorials. So you really need to search Google for that.

However for this specific problem of yours.

The following code should open

1- "http://bloggersentral.blogspot.com/" in the same page where the link is.

2- "http://www.tourism.gov.my/" in a new browser window or a new browser tab

3- "http://www.tic.kelantan.gov.my/" in another new browser window or another new browser tab

This anchor opens three links in a single click

In above code the attribute “target” is relative to the attribute “href”. Only the link specified in “href” will open in the specified “target”.

As said “_self” will open it within the same page where the link is shown.

And the attribute “onclick” is relative to external Javascript which will not check other parameters in the anchor tag unless specified within the Javascript.

window.open("http://www.tourism.gov.my/");

window.open(“http://www.tic.kelantan.gov.my/”);

above code is a set of two Javascript statements which are opening two different pages without looking for any target place as you haven’t specified any target in these statements. And again, the attribute “target” in the anchor tag will not help these statement.

* The second parameter in window.open() method is used to specify a name of the window (any already opened window but you must know a name[handler] to that window).

you are using only first parameter in this method. Provide the second parameter with a name and that name will be a key for later usage.

means onces opened, you will need to specify that name whenever you want to target that window again with another link.

http://www.w3schools.com/jsref/met_win_open.asp

The behavior of this parameter is just same as of the attribute “target” in anchor tag. That says, you can also specify the same values in 2nd parameter of window.open, as you provide in the attribute “target” in anchor tag.

Hope this clears the concept well?

But I am pretty confused when say

[quote=", post:, topic:"]
whenever i click the shortcut of above code
[/quote]

what do you mean by shortcut?

are you talking about the link generated on the page with above code “This anchor opens three links in a single click”? I believe so.

Well for your requirement to open all three links in already opened 3 windows, you must have known the names of the windows. “names” as I explained above. If you don’t know the names of the windows, I am afraid you can’t access those windows from a webpage.

But if you have some kind of flow to open a link always in one window which opens at first for that link, you just need to specify a name while opening a page with window.open().

For example

window.open(“http://google.com.pk”,“GooglePakistan”); will open the link in a new window if there is no already opened window named “GooglePakistan”. If you don’t close that window now and click again on the link, this will open the link in this already open window named “GooglePakistan”.