Dark Knight Posted October 29, 2007 Share Posted October 29, 2007 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 More sharing options...
justsomeguy Posted October 29, 2007 Share Posted October 29, 2007 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 More sharing options...
Synook Posted October 30, 2007 Share Posted October 30, 2007 Do you want var originalURL = (document.referrer) ? document.referrer | 'Referrer unknown'; Link to comment Share on other sites More sharing options...
justsomeguy Posted October 30, 2007 Share Posted October 30, 2007 That last | should be a : Link to comment Share on other sites More sharing options...
Dark Knight Posted October 30, 2007 Author Share Posted October 30, 2007 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 More sharing options...
justsomeguy Posted October 30, 2007 Share Posted October 30, 2007 <script language="JavaScript">var originalURL = document.referrer != "" ? document.referrer : "";function goTo(url){ location.href = url+'?'+ escape(originalURL);}</script> Link to comment Share on other sites More sharing options...
Dark Knight Posted October 30, 2007 Author Share Posted October 30, 2007 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 More sharing options...
justsomeguy Posted October 30, 2007 Share Posted October 30, 2007 Because you're telling it to do that, look at the function. When you call that function to go to a URL you append the referrer onto the end of it for whatever reason. I didn't understand why you did that either. Link to comment Share on other sites More sharing options...
Synook Posted October 31, 2007 Share Posted October 31, 2007 That last | should be a :Oops Link to comment Share on other sites More sharing options...
Dark Knight Posted October 31, 2007 Author Share Posted October 31, 2007 Okey, I've understand now. thanks for you're time. Link to comment Share on other sites More sharing options...
Dark Knight Posted October 31, 2007 Author Share Posted October 31, 2007 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 More sharing options...
justsomeguy Posted October 31, 2007 Share Posted October 31, 2007 If that's all the script does you can just remove it, you don't need Javascript to go to a URL, you can just use a normal <a> tag. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.