Jump to content

goTo url problem


Dark Knight

Recommended Posts

I have a problem with this script:<script language="JavaScript"><!-- var originalURL = document.referrer||'Referrer unknown'function goTo(url){ location.href = url+'?'+ escape(originalURL);}//--></script>This script allow to navigate to a page using:<a href="java script:;" onclick="goTo('history.html');return false">History</a>The problem is thath it dosen't go to that page and still the page exists. any reasons? tnx.

Link to comment
Share on other sites

This isn't doing what you think it is:var originalURL = document.referrer||'Referrer unknown'That is a boolean OR operator, so originalURL is equal to document.referrer OR 'Referrer unknown'. The value of the expression "document.referrer OR <string>" is probably going to be the value "true". It's either going to be true or false. Print originalURL to see what it gets set to.

Link to comment
Share on other sites

Do you want

var originalURL = (document.referrer) ? document.referrer | 'Referrer unknown';

Link to comment
Share on other sites

That last | should be a :
I've tryed to replace the last "|" with a : but appearce a error and dosen't work. If the problem can't be solved than can you show me a script that can go to a page like this: <a href="java script:;" onclick="GO TO URL">Page</a>
Link to comment
Share on other sites

I've tried you're code but it's a problem on the pagelook at this page Visit My Website go to the LICEUL NOSTRU menu and hit the Galerie Foto submenu. Then look at the address bar and it looks like this: http://www.darkknight.3x.ro/sitenou/galeri...enou/index.html WHY?"????

Link to comment
Share on other sites

Okey, I understand now. I've removed var originalURL = document.referrer||'Referrer unknown' and +'?'+ escape(originalURL);. Now the script looks like: function goTo(url){location.href = url;}. Thank you for you're help :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...