PDA

View Full Version : :: why doesnt this work? ::


babelfish
10-22-2002, 03:31 PM
why doesnt this work?

http://www.gazeleyprojects.com/bingen/issue1_english.html

now everything works apart from the swap language part (clicking on the flags)

i have this:

function switchLanguage(what) {
//pathURL=thispage.split('issue')[0];
document.location.href = 'issue' + issueNumber + '_' + what + '.html';
}

and its called like this:

<a href="javascript:;" onMouseOver="document.germanFlag.src='images/germanflagOver.gif'" onMouseOut="document.germanFlag.src='images/germanflag.gif'; languageCustomise()" onClick="switchLanguage('german')">

any ideas why the document.location.href dont work?

thanks!

beetle
10-22-2002, 04:20 PM
Originally posted by babelfish
any ideas why the document.location.href dont work?Most certainly :D

location is a sub-object to window, not document, and as such, is typically inherited (like most window references) unless another window needs to be specified, such as when dealing with frames or popups.

Incorrect
document.location.href

Correct - use dependant upon situation
window.location.href
location.href (same as above)
self.location.href (same as above)
top.location.href
parent.location.href
windowName.location.href
etc...

babelfish
10-22-2002, 04:29 PM
but i have tried all of those to no avail - still wont work :( any more ideas?

basically i just want to open up the links in the same page:confused:

beetle
10-22-2002, 04:45 PM
Alert the concatenation you have...see if it's being built properly...

'issue' + issueNumber + '_' + what + '.html';

Or, more importantly, make sure issueNumber has the correct value...

RoyW
10-22-2002, 04:53 PM
onclick="switchLanguage('german');return false;"

babelfish
10-22-2002, 04:55 PM
it all alerts ok...

im not sure whats happening - i cant even get a basic window.location.href="http://www.google.com" to work :( wtf is going on?

babelfish
10-22-2002, 04:57 PM
Originally posted by RoyW
onclick="switchLanguage('german');return false;"

weeeeeeeeee thats wierd cos ivenever used that b4 but im sure i have had this metghhod working b4 - most strange!

beetle
10-22-2002, 05:04 PM
Good eye Roy. I was forgetting that if you use an empty javascript: protocol in the href, you need to return false