Forum Moderators: open

Message Too Old, No Replies

Javascript Menu and SE Indexing

         

NeedALife

11:40 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Hi guys. Newbie to javascript here - I know just about enough javascript to make myself dangerous. I want to write a js funcion for my menu so that every time I add or drop a product I don't have to change every single page. If all my links are inside the js file with only a document.write(menu()) on the actual pages themselves, will the bots still be able to index and follow the links? I know you can do it in shtml, PHP, etc, but even javascript is a stretch for me so anything more complicated isn't an option.

Any help would be much appreciated.

Bernard Marx

11:56 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, I don't think they will. They don't execute JS (as yet).

If PHP ¦¦ ASP is too tricky, how about SSI? You keep the menu HTML in a single file, then pull it in with a single SSI tag. In fact, it's 10 times easier than using JS.

NeedALife

1:05 am on Sep 10, 2005 (gmt 0)

10+ Year Member



Just looked that up. So I take the whole menu, complete with formatting that relate to css etc, save it as say menu.html, then where I want the menu to go I put <?php require("menu.html");?>? Is that correct? Seems easy enough if it is...

However, then I need to save the files as php files, right? So I lose my rankings with the pages that have html extensions? If so, at least I can do this for any new sites I build, and one that I'm far enough down that no one would notice. Or do I have this wrong?

Bernard Marx

1:46 am on Sep 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



require()

I guess so. Not an issue I'm experienced with, though it sounds like

include()
may be preferable

The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.

(The PHP Manual: [php.net...]

Try here for all the ammo:
[webmasterworld.com...]

Changing file extensions.

Yes, this is an issue (with all server scripting langs). There are a couple of solutions.

1) It's not so hard to direct your server to process the PHP in all

.html
files, or those within certain directories. This isn't inefficient if all your files in those directories contain some PHP.

2) On Apache/Unix you can, distinguish those

.html
files that you want PHP-processed by setting them as executeables. The "XBitHack"?

If you're likely to change your scripting language in the future, these options may still be good.

Try: [webmasterworld.com...]

Good luck.