PDA

View Full Version : dhtmlwindow variable path button images



JanPaul
03-24-2008, 04:01 PM
1) Script Title: DHTML Window widget (v1.1)

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem:
I'm using the dhtmlwindow in a JAlbum photo album in order to show the location of the photo in a separate window showing Google Map with a placemark.
See: http://home.planet.nl/~paul0979//Test%20environment/index.html
The dhtml window can be activated by the small globe button on the top right hand of the picture pages.

On the first level the dhtmlwindow button images aren't found.
On the second level the are OK
On teh 3rd level they aren't found.


Since dhtmlwindow.js has a fixed path to the 'button images'in the dhtmlwindow.js script this doesn't work for nested folders.

Therefore I want to parse a variable path name from a html page to dhtmlwindow.js in order to use the same dhtmlwindow.js script from various html-pages in nested folder structure.

Depending the depth of the folder I want to have the path name set at:
/res/windowfiles
../res/windowfiles
../../res/windowfiles
etc. etc.



In dhtmlwindow.js I want to replace "/windowfiles" path with some kind of variable that is parced from the html-page calling dhtmlwindow.

In the original dhtml.js file the images are defined as:
imagefiles:['/windowfiles/min.gif', '/windowfiles/close.gif', '/windowfiles/restore.gif', '/windowfiles/resize.gif'], //Path to 4 images used by script, in that order


Hopefully somebody has an idea.

Many thanks, Jan

ddadmin
03-24-2008, 08:39 PM
Hmm why not just specify absolute URLs to all the files referenced by and inside the DHTML window? For the gifs for example, you'd change it to something like:


imagefiles:['http://mysite.com/windowfiles/min.gif', 'http://mysite.com/windowfiles/close.gif', 'http://mysite.com/windowfiles/restore.gif', 'http://mysite.com/windowfiles/resize.gif'], //Path to 4 images used by script, in that order

Do the same for the references to the .js and .css files of the script itself in the HEAD section of your pages.

JanPaul
03-25-2008, 09:45 PM
Indeed that would work, but the idea was to have it flexible in a way that it would be possible to generate the photo album without any absolute URL's.
JAlbum is set up in that way, and that works great.

For references to the .js and .css files it works fine, since these path's are created in the JAlbum script, but the above image path's are fixed in the .js script file.

Regards, Jan

ddadmin
03-25-2008, 10:24 PM
Hmm well you can replace "window/" inside any mention of it inside the .js file, such as:


imagefiles:['/windowfiles/min.gif', '/windowfiles/close.gif', '/windowfiles/restore.gif', '/windowfiles/resize.gif'], //Path to 4 images used by script, in that order

with a dynamic variable that changes based on where the file is called. Doing this on the server side, you would first rename dhtmlwindow.js to dhtmlwindow.php instead, which makes it possible to include PHP variables within its contents, such as:


imagefiles:['<?echo $dynamicvar;?>min.gif', '<?echo $dynamicvar;?>close.gif', '<?echo $dynamicvar;?>restore.gif', '<?echo $dynamicvar;?>resize.gif'], //Path to 4 images used by script, in that order

This all assumes you have $dynamicvar pre-populated with the appropriate path depending on where dhtmlwindow.php is being called from at the moment etc.

You can potentially do this without involving the server side (ie: no renaming of .js to .php), but then the tricky part becomes trying to figure out what the dynamic path should be, since using server side provides a lot more flexibility in figuring out things about the server than using JavaScript.

JanPaul
03-26-2008, 08:26 PM
The dynamic path is known within the html page form which the dhtmlwindow-script is called.
Depending the depth of the folder structure it looks like ../res or ../../res etc.

My idea was to add an extra variable to the dhtmlwindow.open function. But I'm not an experienced programmer and I can't figure out how I can this should work.

The code at the html page looks like:
<link rel="stylesheet" href="../res/windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="../res/windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>


And div mijn_kaart looks like:
<div id="mijn_kaart" style="display:none">
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http:PICT0811_MAP.HTML"></iframe>
</div>

And the call of the dhtmlwindow looks like:
onmousedown="divwin=dhtmlwindow.open('divbox', 'div', 'mijn_kaart', 'Kaart', 'width=425px,height=350px,left=150px,top=150px,resize=0,scrolling=0');"

Can I add an argument to the dhtmlwindow.open function and use that content in the dhtmlwindow.js script to define the path of the images?

ddadmin
03-27-2008, 03:47 AM
Can I add an argument to the dhtmlwindow.open function and use that content in the dhtmlwindow.js script to define the path of the images?

Sure, but even easier would be to directly override the paths of the images within dhtmlwindow.js on the top of your pages (HEAD section), with something like:


<script type="text/javascript">
dhtmlwindow.imagefiles=['../rss/min.gif', '../rss/close.gif', '../rss/restore.gif', '../rss/resize.gif']
</script>

Make sure the above is defined after the reference code to dhtmlwindow.js on your page. This causes the DHTML window on that page to use the above paths for its icons, instead of the default.

JanPaul
03-27-2008, 09:12 PM
That's a really good advise. I always start to look for complex sollutions while the simple ones are really close by.

Many many thanks,
Jan

cyberd
04-05-2008, 06:31 AM
hi and sorry...

i had make a mistake post in different subject thread... gouxou... (sorry for bad english!)

my post is:

http://www.dynamicdrive.com/forums/showthread.php?t=31135

and may must be in Dynamic Drive Forums > DD Scripts > Dynamic Drive scripts help ...

so if admin or mod see my error plz move it... and may be the god or someone could help me...

Sorry and thanx in advance... :-(