Jump to content

Making target link


Hades

Recommended Posts

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

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

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

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 by Dan The Prof
Link to comment
Share on other sites

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 by Hades
Link to comment
Share on other sites

Im trying to get it on my website to make people i dislike from accessing some details
Hades, 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...