/    Sign up×
Community /Pin to ProfileBookmark

onUnload function not quite working

Heres our script

function Exit()
{
var bye;
bye=document.this.location.href
if(bye!=(“58001.html”,”58001.htm”,”58002.html”,”58002.htm”,”58003.html”,”58003.htm”,”58004.html”,”58004.htm”,”chooseBottom.htm”,”chooseTop.htm”))
top.frames[‘ProductBottom’].location=”ChooseBottom.htm”;
}

<body onUnload=”javascript:Exit();”>

we have 2 frames, if you click to a different page in the bottom frame, we want the top frame to default back to the home page. But certian pages should not cause this switch.

We are trying to make the variable “bye” equal the currect page href. Then check that agains the list of acceptions, it if its NOT on the list, then change the top frame location.

doesnt seem to be working but i dont know why.

thanks for the help

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@JB1981authorJun 11.2004 — the space in java and script above is not in my script, thats a typo here.
Copy linkTweet thisAlerts:
@David_HarrisonJun 11.2004 — It didn't work because your code didn't make any sense, what was all this about ("","",""), that's not how you make an array, and you can't compare a string to an array anyway.

Try this code instead:&lt;script type="text/javascript"&gt;&lt;!--

var bye=location.href.substring(location.href.lastIndexOf("/"),location.href.lastIndexOf("."));
var pages=new Array("58001","58002","58003","58004","chooseBottom","chooseTop");

function exit(){

for(var n=0;n&lt;pages.length;n++){
if(bye==pages[n]){break;}
}

if(n==pages.length){
top.frames['ProductBottom'].location.href="ChooseBottom.htm";
}

}

//--&gt;&lt;/script&gt;

&lt;body onunload="exit();"&gt;
Copy linkTweet thisAlerts:
@hansonc01Jun 11.2004 — well it does make sense kinda, we just don't know how to do it.

The htm's in the quotes is what we are checking against.

What we are trying to do is, set it that so if any of the options that we choose in another frame, end or goto 5800?.htm then to not load "ChooseTop.htm" else load it.

Your script didn't work.

But here is more source to understand fully.

//This is in the lower frame, which calls for any of those options to load that link in 1 of the 2 middle frames, named ProductTop and ProductBottom

</select>

<select onChange="top.frames['ProductTop'].location=this.options[this.selectedIndex].value; top.frames['ProductBottom'].location=this.options[this.selectedIndex].value+'l';">

<option value="ChooseTop.htm">Choose Item</option>

<option value="58003.htm">Show Pony</option>

<option value="58002.htm">Alias</option>

<option value="58004.htm">A.K.A</option>

<option value="58001.htm">One Icon</option>

</select>

//We need it so that if we choose one of those options it will reload those two frames, ProductTop/Bottom, with that link. However we have other products that we need to load a certain top/bottom, ChooseTop/Bottom.htm, depending on the type. The code needs to go into 58001-4.

I hope this makes sense, refering to the previous code if need be. Please continue to help. :-)
Copy linkTweet thisAlerts:
@David_HarrisonJun 11.2004 — I'm still not entirely sure what you're after, do you have a link to this page?

When I said it didn't make any sense, I meant that it wouldn't make sense to a browser trying to parse the code. You were comparing data types that you just can't compare, and your array wasn't an array.
Copy linkTweet thisAlerts:
@hansonc01Jun 11.2004 — Unfortunately its not on the web, nor will it ever goto the web.

I guess how can we make an if statement out of the inputs that we have?

Think of it as categories.

Say I have Bottles, Guns, Brooms, Brushes and Pans.

Pans and Bottles get toaded to ProductTop and Guns and Brushes get loaded to ProductBottom. Well you can view Bottle or Pan products while viewing Guns or Brushes on the bottom, but Brooms <58001-4.htm> are so tall they need to take up both frames. So we cut the brooms in half load them to top and bottom. So when we switch to another broom we want it to continue loading to both frames, however if you just choose Guns we want the Top frame to goto a default image/page, sort of a no selection page this would be the ChooseTop.htm.
Copy linkTweet thisAlerts:
@David_HarrisonJun 11.2004 — Try this:&lt;script type="text/javascript"&gt;&lt;!--

var bye=location.href;

function exit(){

if(bye.indexOf("5800")&lt;0){
top.frames['ProductBottom'].location.href="ChooseBottom.htm";
}

}

//--&gt;&lt;/script&gt;

&lt;body onunload="exit();"&gt;
Copy linkTweet thisAlerts:
@hansonc01Jun 11.2004 — Hey right on that looks alot more along the lines of what we were thinking of. I appreciate your help. Thank you!!
Copy linkTweet thisAlerts:
@David_HarrisonJun 11.2004 — Happy to help. ?
×

Success!

Help @JB1981 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...