PDA

View Full Version : function newWindow within a newWindow links don't work


brownbear51
09-15-2004, 06:59 PM
Page one has links that uses the function newWindow script, works fine.
Page two which opens from page one also has links and new
Window script.
If page two opened from page one's links, page two's links do not work.
If page two opened from homepage link (newWindow script not used, just a straight hyperlink), then page two's links work.
It appears the newWindow function is only working once? Yes, I'm a novice. :eek:
Can anyone help and thanks! Following are the pages and the script I'm using.

Page one link is:
http://www.ucsf.edu/scor/about/about.html
The link is called Scor Research from this page and opens page two in a new window, then the newwindow links on page two doesn't work.
Page two link:
http://www.ucsf.edu/scor/research/research.html
If you go go page two directly without going through page one the links all work.


<head>
<script language="JavaScript" type="text/JavaScript">
<!--
function newWindow(theURL,winName,features) { //v2.0
picWin = window.open(theURL,winName,features);
picWin.focus();
}
//-->
</script>
<//head>

<body>
<a href=javascript:;

onClick="newWindow('http://www.ucsf.edu/scor/links/relatedprojects.html','bio','scrollbars=yes,resizable=yes')"><font

color="#996600">SCORResearch</font></a>
<//body>

Mr J
09-15-2004, 07:49 PM
The links in page2 are using the same winName as the links in page1.

This should mean that a link in page2 opens a page into the window opened by page1.

But I notice in your links you have <a href=javascript:; onClick="newWindow('http://www.ucsf.edu/scor/lin ...............

I have never seen this used like this before usually it's like

<a href="#null" onClick="newWindow('http://www.ucsf.edu/scor/lin.....

If you are wanting to open a second new window from links in page2 you will have to use a different winName for the links in page2.

Roy Sinclair
09-15-2004, 07:53 PM
Why are you even bothering to open new windows? I don't see any advantage this gives you and I can definitely tell you that it can be a real annoyance to a great many people. It's using that script instead of just using regular links which is behind this problem so if you get rid of the "new windows" stuff and just use everyday links you can solve this problem quite easily. Based on the URL you posted I'd also guess that you've got an requirement to make your pages "accessible" which is a requirement that using that the new windows script makes sure you won't be able to meet.

brownbear51
09-15-2004, 08:00 PM
Because we want the main page to stay open so the reader doesn't lose his/her place. There are many links which change constantly as it is a research site so the design is such the reader can go off on their own without losing where they came from. It is a design decision made by many, not just one.

No, it is not a public site and it is not meant to be found by the public.

Now, do you have any useful suggestions for me? I asked for help on the new windows script, not the design.

:D

brownbear51
09-15-2004, 08:01 PM
I will read up and try to follow from my javascript 4 book, just copying code and not really understanding it. I appreciate your help. :thumbsup:

Roy Sinclair
09-15-2004, 08:08 PM
Your argument about users getting lost really doesn't hold any water but as long as your audience can all come by and complain to you in person I don't see any reason why you can't open all the windows you want :eek: . I guess the next question is whether you want every new page to open in a new browser window or if you just want all pages after that first link the user follows to open in the new window you create.

Mr J. has advice that may help but I've noted that your problem seems to be specific to the IE browser, I can navigate just fine from the second page using the Firefox browser.

Mr J
09-15-2004, 11:07 PM
The following script will open a new window for any link that uses the function


<script>
<!--
function newWindow(theURL){
picWin = window.open(theURL,'','scrollbars=yes,resizable=yes');
picWin.focus();
}
//-->
</script>

<a href="#null" onClick="newWindow('http://www.ucsf.edu/scor/links/PressRelease.html')">Press Releases</a><BR>
<a href="#null" onClick="newWindow('http://www.ucsf.edu/scor/links/collaborators.html')">SCOR Collaborators</a><BR>
<a href="#null" onClick="newWindow('http://www.ucsf.edu/scor/research/research.html')">SCOR Research</a><BR>
<a href="#null" onClick="newWindow('http://www.ucsf.edu/scor/links/publications.html')">Publications</a><BR>

Willy Duitt
09-16-2004, 12:30 AM
Now, do you have any useful suggestions for me? I asked for help on the new windows script, not the design.

Although you failed to understand Mr. J's suggestion.... What he suggested is the correct solution and would not only solve your problem but also make your site accessible....

I suppose you are stuck on the new windows thing because you do not know any better but I'll give it another shot...

Use the anchor href as intended and use the target attribute to open each link in a new window....


<a href="http://www.ucsf.edu/scor/links/PressRelease.html" target="_blank">Press Releases</a><BR>


.....Willy

FlyingsCool
08-13-2006, 02:37 AM
Oops - Nevermind