big-dog1965 Posted October 20, 2009 Share Posted October 20, 2009 Can I control attributes with a .js file for a webpageI would like to have background-repeat: repeat-x; background-attachment: fixedThis displays my image but cant figure out how to get the attributes to work {function menubar() retVal = "<img src=images/blk_pipe.gif>"; return retVal;} Link to comment Share on other sites More sharing options...
chibineku Posted October 20, 2009 Share Posted October 20, 2009 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 More sharing options...
big-dog1965 Posted October 20, 2009 Author Share Posted October 20, 2009 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 More sharing options...
chibineku Posted October 20, 2009 Share Posted October 20, 2009 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 More sharing options...
big-dog1965 Posted October 22, 2009 Author Share Posted October 22, 2009 My general idea was to have a .js file that has all the images and all menus for the web pages so I only have to change them in that file to update the site. Link to comment Share on other sites More sharing options...
chibineku Posted October 22, 2009 Share Posted October 22, 2009 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 More sharing options...
big-dog1965 Posted October 22, 2009 Author Share Posted October 22, 2009 OkI got another post out there about formatting of page using CSS so if I can get a good responce on that then I will get back to this post. my host does suport php so with some help I think that is the direction to go. Link to comment Share on other sites More sharing options...
big-dog1965 Posted October 23, 2009 Author Share Posted October 23, 2009 I have completely started over with page ideaIm thinking if I keep these two threads up dated Ill get the thing right as I go.CSS FORMATLeft, center, and right will be populated with database information. The center needs to have a splash type page that changes each month and the links on site will pop up in the center area also. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.