Forum Moderators: open

Message Too Old, No Replies

New Window Probs

Causing a hyperlink to open a new window, and other links into the same one

         

brotherhood of LAN

8:20 am on Feb 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Another post about my almost legendary dictionary :)

As a supposed means of SEO, I am going to put hyperlinked keywords below each of the titles in my tutorial pages, linking to the dictionary elaborated upon in the page content. I am doing this because

1. It points out the functionality of the dictionary on the site (to be used in conjunction with tutorials)
2. It adds more prominence to the keywords associated with that page
3. It helps the search engines to reach the data hidden within my database

So all is good

The thing is, if someone is going to be reading the tutorial, they will want the terms to be in a new window when they click on them. So do sort this, i use the _blank attribute to the hyperlink. The thing is, if i have 10 links to the dictionary, I do not want the user to have to have open 10 browser windows. Preferably, by clicking one and opening the term in the new window, I would want the other 9 to load up in that window!

I have seen this done before and am sure that someone in here knows what Im on about.

Info very much appreciated!

LAN

knighty

9:10 am on Feb 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you need is a pop-up window.

The user clicks a link and a small window appears explaining all they click on another link and the same window they opened previously reloads with new content. Just make sure you give the pop a name and use it for all our links.

tedster

9:26 am on Feb 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yup, you need a pop-up window so that every link loads in the same window.

The thing is, you also want the spiders to follow the links, and they won't read the variables in a javascript pop-up function. So, assuming your pop-up function is popUp(url,windowname), use this format for your links:

<a href="dictionary.html" onClick="popUp('dictionary.html','dict');return false;">

Don't forget the "return false" -- it keeps your main window from loading the new document.

I've been using this on several sites, and it works well. It also provides access to the dictionary page for visitors who have js turned off.

brotherhood of LAN

6:38 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So I assume Javascript is my only option

Anyone know of the smallest, free javascript to open a new window?? :o)

I know they are out there, but personal recommending one is so much better :)

Marcia

6:46 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I once heard that there is a way to do them opening in one window, but can't remember how, or which word was used - blank, top or whatever. I think it had something to do with whether or not the word was prefixed by an underscore.

rcjordan

6:49 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>free

Take a look at this thread

[webmasterworld.com...]

Black Knight

9:34 pm on Feb 9, 2002 (gmt 0)

10+ Year Member



Hi. What you are looking for in your first post is simple and doesn't need JavaScript.

Set the target attribute to TARGET="dictionary" and if there is no open window already called "dictionary it will open a new window just like TARGET="_blank" does. However, if there is already a window opened this way called "dictionary" (i.e. they still have that last new window open somewhere) it uses that same window as the target.

Case solved.

Ammon Johns

tedster

9:42 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, Black Knight. You are 100% correct.

Sometimes I'm so involved with what I'm up to, I overlook the obvious.

brotherhood of LAN

9:43 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Black Knight that would be ok, but each target is different for each term i.e.

dictionary.asp?Term=Cell
dictionary.asp?Term=Chromosome etc

Tedster, I tried you approach, thanks for the pointer, the thing is, they dont load up in a new window, they load up in the same window.

Even if I use the _blank attribute, they all open up in different windows, which defeats the purpose

example of my link
(a href="http://www.biology-online.org/dictionary.asp?Term=Cell" onClick="popUp('dictionary.asp','dict');return false;" target="_blank">Cell</a)

(changed the opening n endingg tags in case they are rendered)

so what alterations are required? Thanks for the info so far peeps :)

Richard

tedster

10:58 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> the thing is, they dont load up in a new window, they load up in the same window.

Not quite clear what you mean here. I thought you wanted your user to only have one new window no matter how many terms were clicked.

If you do want to load the link in a new window, you can use a different window name for the second parameter in the function. (i.e. 'dict1', 'dict2' etc.) The ;return false; section should keep the document from loading in your main window.

Maybe there's a complication with ASP that I'm not aware of. That's not an area I play with.

>> Even if I use the _blank attribute, they all open up in different windows, which defeats the purpose

I understood Black Knight as NOT recommending target="_blank", but instead suggesting you use target="somewindowname" The target="_blank" attribute is a reserved name with it's own behavior.

brotherhood of LAN

11:36 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In light of me getting a little confused, Ive went with this little javascript. Any link to the dictionary opens the new window and subsequent links pointing to the same page uses the same window as desired. To all the above, thanks for the pointers, I'll stick with the below JS for now!!!

<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function Start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}
// End -->
</SCRIPT>
</HEAD>

<BODY>
<a href="javascript:Start('http://www.webmasterworld.com')";>Webmaster World</a>
</BODY>

So ok, I have about 100 tutorial pages this script will be used on. This would mean using that code that goes in the head 100 times, which is not desirable. I believe its possible to link to a .js file externally??

I.E. I ask this because surely after a visitor has executed the script once, they will no longer have to receive the script from the server again and again. Can someone give me the pointers to do such a thing?

tedster

11:52 pm on Feb 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To call a javascript from an external file, place this in the HEAD section:

<script type="text/javascript" language="JavaScript" src="filename.js"></script>

The .js file doesn't contain any script tags or comment tags to hide from old browsers -- just the code

brotherhood of LAN

12:04 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



BOTH FILES ARE IN SAME DIRECTORY, THE ROOT

<head>
<title>New Page 1</title>
<script type="text/javascript" language="JavaScript" src="1.js"></script>
</head>

<body>
<a href="javascript:Start('http://www.yahoo.com')";>Yahoo</a><br>
<a href="javascript:Start('http://www.google.com')";>Google</a>
</body>

It returns with error on page. Any ideas?

brotherhood of LAN

12:12 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



P.S. The external Javascript file the 1.js file

i just copied and pasted it into notepad n it looks like this

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function Start(page) {
OpenWin = this.open(page, "CtrlWindow", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}
// End -->
</SCRIPT>

tedster

12:17 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In your links -- you don't need the semicolon after the close quote.

brotherhood of LAN

12:25 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The links now look like

<a href="javascript:Start('http://www.yahoo.com')">Yahoo</a><br>
<a href="javascript:Start('http://www.google.com')">Google</a>

Still get the "Error on Page" in the status toolbar

tedster

3:50 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In an external file you should NOT use <script> tags. Also no <!-- Begin or //End--> comments. Just being a .js file handles all those worries.

After cleaning out the above, try this for your function definition:

function Start(page) {
window.open(page, "CtrlWindow", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}

brotherhood of LAN

3:57 am on Feb 10, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You know what? Problem solved! Cheers Teddy Boy!!

A1, Blue Peter Badge is in the post, thanks for the info

Richard