Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Javascript in header?


prazim

Recommended Posts

I have a small piece of javascript code I'd like to include in the header of each section of my gift shop. Simply pasting the code in doesn't work. How do I do this?

Thanks,

Sue

 

 

javascript is normally placed within the <head> </head> tags in an page.

If the javascripts placement within the page isn't critical it could be added to header.php ...

If it is critical you'd need to add it to the relevant php files within the Catalog directory (just the ones in the root, not the sub-folders)

Link to comment
Share on other sites

Well, I would like the javascript to be at the top of the page, for every page a customer visits which is why I was going to place it in header.php. Do I place the javascript with <head> codes before any php code?

thanks,

Sue

 

javascript is normally placed within the <head> </head> tags in an page.

If the javascripts placement within the page isn't critical it could be added to header.php ...

If it is critical you'd need to add it to the relevant php files within the Catalog directory (just the ones in the root, not the sub-folders)

Link to comment
Share on other sites

Some Javascript code wont work unless its within the <head></head> tag - others will

the problem with placing the javascript in /catalog/includes/header.php is that the header file is included in every page AFTER the closing <head> tag and in the <body> tag - so by placing it in the header.php file your placing your javascript code in the body tag on every page the header.php file is included

and if placing the Javascript code in header.php , do NOT enclose it within <head></head> tags or your pages are going to have 2 <head> tags

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...