Forum Moderators: open
Yes, it's a pretty safe assumption.
>> Is there an advantage to doing this--making my javascripts external <<
1. It brings your content closer to the top of the html page. This is great for the spiders. Sometimes when there is lots of js on the page, they never get to your content at all, and you end up with only the js in their database!
2. Write the javascript once and call it from any page on the site -- instead of re-writing it on every page that needs the function.
3. The js file is cached by the client, meaning that after one download, all other pages will load faster.
>> "using a js redirect in an external file none of the engines will know this if it is external..."
I've heard this. Won't the search engines index the page that you are re-directing to instead of the actual page? <<
No, the spiders almost never call the js file and will not see the redirect URL at all. Right now search engines would have a lot of security issues trying to automatically run your js on their machines to find out what it does.
Google has said they "reserve the right to check your js in the future", but even this technical monster doesn't routinely check js files right now.
So the head section is safe. What about the <body>. Are external js files safe to use in the body area?
The best part about external .JS files is that if a spider does ever want to look at your .JS files, your logs will tell you about it, allowing you to know that whatever spider is suddnly interested in javascript for some reason. That's a handy alarm system to have.
help would be appreciated !!
Find everything you need to know (and them some) about controlling windows with javascript here [developer.irt.org].
ponytale asked:
>> i need javascript to selfclose a popup window after login (the login opens a new window) <<
My apology to ponytale -- this question was ignored for an entire month. A very belated welcome to the Forum, and I hope this information helps, now or in the future.
The javascript method for closing a window is window.close().
If you use it to close a window that your javascript code opened (the popup in this case) it works without presenting a confirmation alert window. If you use it to close a window that your js didn't open, the user will automatically get the request to confirm the close.
To close the pop-up window when the user's login is submitted, you could call it by including the onSubmit() event handler in the login FORM tag:
<form name="loginform" onSubmit()=window.close()>form content goes here</form>
However, that code might be problematic if the submitted login doesn't validate. You could account for that possibility by having a failed login generate its own, new popup window for the failure message.