Jump to content

Using .js File With Webpage


big-dog1965
 Share

Recommended Posts

Well, you can't make an image repeat by setting the repeat attributes of the image. You need to set that image as the background for an element that will accept an image background (which is most of them). So, you can either extract the URL from that image or do it a different way. Do you know the element you will be setting that image as the background for? To answer your original question, you can do it, but I need to know more to help you with actually doing it.

Link to comment
Share on other sites

Well, you can't make an image repeat by setting the repeat attributes of the image. You need to set that image as the background for an element that will accept an image background (which is most of them). So, you can either extract the URL from that image or do it a different way. Do you know the element you will be setting that image as the background for? To answer your original question, you can do it, but I need to know more to help you with actually doing it.
Here is what I got in the weppage that displays the image <div id="nav"><script>document.write(menubar());</script> </div> </div>
Link to comment
Share on other sites

The hair stand up on the back of my neck when I see document.write(), as they do for everyone else who has used it. document.write() works, but it only works once and it's a pretty ugly use of javascript. If you call document.write any time after a page has loaded, you will wipe the whole page. That's reason one it's not used widely. Okay, that aside, can I ask for more details of what you want to accomplish overall by having javascript do this? It's hard to think of a good solution without knowing implementation.

Link to comment
Share on other sites

hm, okay. The other way is to use very obvious filenames, like 'menuContact.jpeg', 'menuAbout.jpeg' and then if you want to change image you just save the new image with the standard filename and Bob's your uncle. Whenever you introduce JavaScript, you introduce the possibility that a number of users won't get the content. It's a design decision, of course, and if your site isn't commercial then it's entirely at your own whim. The other way is to use PHP includes to include the HTML of your menus. That way, you only need to change the menu in one document for it to have site-wide effect. All you need to do is make sure your server supports PHP, cut and paste the exact HTML you use to display your menu, or a standard header, or anything else that is used on lots of pages, and where you removed it put:<?php include("menu.html"); ?>You need to save your pages as .php as well, but once that's done, any change you need to make to your menu is quick and painless. It also makes loading a little quicker, I think.If you don't want the .php extension on your pages, you can mask that, too, with relative ease. If that still isn't what you want, I'll try to help with the javascript thing, but I think there are better ways and less effort. Plus PHP isn't something that depends on the user's browser settings - it can't be turned off.

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
 Share

×
×
  • Create New...