TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

creating var in javascript and then access in html code

Page: 1 Reply
Sep 26th 2003#122471 Report
Member since: Jun 14th 2002
Posts: 60
i am creating a bigg page that will have lots of images that will have the same url..my idea to turn the page size smaller is to put at the top of the page a var with the url of the images and then just put in the images 'src' tag the var , this way by each image i get like less 50 chars(in let's say 100 images i am gettin 5000 chars and it will be a lot more than that!)

so how can i do that?

i put at the top of the code:


and now

Reply with Quote Reply
Sep 27th 2003#122526 Report
Member since: Jun 30th 2001
Posts: 447
I'm assuming that the images are on the same server as your web page with all the images. If so, you should try using relative URL's instead of the full URL, e.g., /mysite/images/image.jpg vs. http://www.mysite.com/mysite/images/image.jpg.

If you are already doing this, I don't see why you want to create a JavaScript variable. It would end up being the same page size (maybe bigger) with or without JavaScript because you have to declare the use of JavaScript before printing any variable.

As an alternative, you could create a JavaScript array with all the filenames and a variable with the path, then have JavaScript loop through the array and print it out. Or even better, use PHP, or some server side language, to do this.
Reply with Quote Reply
Sep 27th 2003#122530 Report
Member since: Jun 14th 2002
Posts: 60
no its not in the same url so i cant put relativa path, i really must put the full path
Reply with Quote Reply
Sep 28th 2003#122628 Report
Member since: Jun 30th 2001
Posts: 447
Then I suggest you do what I mentioned in the third paragraph. If you don't want to do that, then I will give you the code for what you want to do.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum