Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help from a Javascript Guru...

Status
Not open for further replies.

Weishun

Technical User
Sep 4, 2000
2
CA
I've got a p/w script with a redirect to prevent direct access to the protected page...works really well. Problem is, the page needs to be refreshed, from time to time, after login and the script won't allow it. Found a p/w cookie script that I think could be integerated to allow the refresh but can't figure out how to do it.

Also, I've got a menu script that's really neat and I'd like to use it on a number of pages. Problem is, I only want to have to edit one file when links change and, while I think it can be done with a js file, haven't been able to figure out how to make it work.

If you're willing and able to help, you'd earn my undying gratitude and a 24. :cool: [sig][/sig]
 
What do you mean by "the script won't allow it". Need more info there. Refreshing the page should be pretty straight forward. If you are referencing a variable that no longer exists after a refresh you may run into problems.

You need to put the .js file within a script tag ala...

Code:
<script language=&quot;javascript&quot; src=&quot;menu.js&quot;>

Note that the .js file does *not* need <script> tags.

the best way (for me anyway) to set up links in menu.js would be to define an array that contains...
1. Link Name
2. Link Href
3. Link alt
4. whatever else the menu needs to work
so your code would look something like this...
Code:
 menu[1] = new Array(&quot;Link Name&quot;,&quot;[URL unfurl="true"]http://www.link.com&quot;,&quot;Link[/URL] Alt&quot;);
 //etc.

you would then parse out each piece of the array with a .split function as you create your menu on the fly. I have used this technique many times and it makes it extremely easy to edit the links and when using the src=blah.js you only need to edit one file for a site-wide change. It also makes it easy, if you use server-side scripting, to use a database to store the links rather than an array within the script.


Hope it helps and if you need clarification feel free to ask,
Rob [sig][/sig]
 
Menu) Go to and peruse their menu/navigation examples. You will be *much* happier with them than the one you have now and should be able to more easily integrate the ideas I gave you about arrays.

Cookies) go to for a way to do what you want to do without using cookies (which are sometimes disabled by the end-user). If you decide you want to use cookies that same site can give you some much easier examples than the page you had. If you still need help though, ask.

Warning: The javascript you are using to verify passwords seems like it would probably be pretty easy to hack. If you have very sensitive info on the other side you may want to think about getting away from Xoom and trying a service that provide ASP (active server page) which is much more powerful and -since there is server-side processing- is much less likely to be hacked (though anything is possible). SSL (secure sockets layer) and https (http secure) may also be offerings of another provider. Just a friendly warning :)I .

If you need anything else,
Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top