Hades Posted May 19, 2006 Share Posted May 19, 2006 I got this off a website and wanted to put it in my website. Everything has been credited, except I cant get the script to link to a website rather than a file on my computer. Any suggestions? I believe the code requiring changing are in "b" tags <HEAD><script type="text/javascript"><!-- Begin/* This script and many more are available free online atThe JavaScript Source :: http://javascript.internet.comCreated by: Javascript Newbie :: http://expage.com/javascriptnewbie*/var password;var pass1 = "pass"; // place password herepassword=prompt("Please enter your password:","");if (password==pass1) { [B]window.location= "<location>"[/B]; // file to open if password is correct} else { window.location= "test.html"; // file to load if password is incorrect}// End --></script><p><center><font face="arial, helvetica" size"-2">Free JavaScripts provided<br>by <a href="http://javascriptsource.com">The JavaScript Source</a></font></center><p><!-- Script Size: 0.81 KB --> Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 19, 2006 Share Posted May 19, 2006 It is not a complete file, first close the <HEAD> section like this: <head><script>....</script></head> And then place all the rest in the body:<head>...</head><body><p>...</p></body> And finally, enclose everything inside the root element: <html><head><script>....</script></head><body><p>...</p></body></html> Link to comment Share on other sites More sharing options...
Hades Posted May 19, 2006 Author Share Posted May 19, 2006 Its not that. Im trying to make it such that when the password is correct, it takes me to another WEBPAGE, not a file on my computer. So therefore it would link to a webpage over the net as Im trying to get it on my website to make people i dislike from accessing some details. Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 19, 2006 Share Posted May 19, 2006 (edited) Could you supply a link to this page, so we could see the source?Or what exactly have you put in as a file to be linked to, between those [b]...[/b] you have put in?[*Edit:]The correct syntax of loading a new page with such instruction, is like this: window.location.href = "file.htm"But if you want to target a frame, then use:document.framename.src = "file.htm" Edited May 19, 2006 by Dan The Prof Link to comment Share on other sites More sharing options...
Hades Posted May 19, 2006 Author Share Posted May 19, 2006 (edited) Unfortunately, as part of secrecy im unable to give the link to the page. I'll give it a try and PM you if it works or not.Oh yay! I think I got it working. Hope it stays like dat. :s Edited May 19, 2006 by Hades Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 19, 2006 Share Posted May 19, 2006 Does it work now? Great (by the way, you are not european are you?) Link to comment Share on other sites More sharing options...
scott100 Posted May 19, 2006 Share Posted May 19, 2006 Im trying to get it on my website to make people i dislike from accessing some detailsHades, you do realise that Javascript is not a secure way of doing this, all anyone has to do is View -> Source and they can look the code and get your password.Any fool could figure this out:var pass1 = "pass"; // place password here If you want to do this securely i suggest doing it on the server side with PHP or ASP not client with Javascript. Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 19, 2006 Share Posted May 19, 2006 But you'll need support for the server-side language, at your webhost. Not every host supports it, but you'll probably be able to figure that out Next, if you want to do it "right", concerning passwords, a database (MySQL) would also be handy, but it is not nessecary. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now