|
I use the following script written by Massimo Foti to make an image appear to always fit the size of the window.
function makeIm() {
NS4=(document.layers);
IE4=(document.all);
scaleWidth = true;
scaleHeight = true;
imSRC = "http://www.myAddress.com/images/banner_04.gif";
if (NS4) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
if (NS4) onresize = reDo;
if (IE4) onresize = reDoIE;
function reDoIE(){
imBG.width = document.body.clientWidth;
imBG.height = document.body.clientHeight;}
winWid = (NS4) ? innerWidth : document.body.clientWidth;
winHgt = (NS4) ? innerHeight : document.body.clientHeight;
imStr = "<div id=elBGim"
+ " style='position:absolute;left ;top ;z-index:-1'>"
+ "<img name='imBG' border='0' src="+imSRC;
if (scaleWidth) imStr += " width="+winWid;
if (scaleHeight) imStr += " height="+winHgt;
imStr += "></div>";
document.write(imStr);}
makeIm();
I use this on about 15 seperate plain html pages, and I change the images weekly. What I am asking is, can i instead of writing:
imSRC = "http://www.myAddress.com/images/banner_04.gif";
can I write a variable that links to an external javascript file that has the addresses to the images. for example if I have a page that's about cars, then I want to write something like imSRC="car" which is linked to a javascript file called "backgrounds.js" which has in it something like:
....
car variable ="http://www.myAddress/images/wednesday_car.jpg
boat variable = "http://www.myAddress/images/wednesday_boat.jpt
...
I want this so I can change the image addresses in one spot instead on each page.
So, how do I set the variable on each page and link to "backgrounds.js" and how do I set up "backgrounds'js".
I realise I can do this more automatically if it was database driven, but I aren't ready for that...
I hope I have clearly explained what I want.
Regards
jaslr
|
|
|
|
|
I can see a bunch of ways to do what you ask, but there are two in specific that I think are the best.
Assuming you want to stick to HTML and JavaScript I would recommend using an include file. That way all of your pages will contain the same referance to an external include file and you will be able to just edit the include file to effectively change all of them. Your include file would simply contain some JavaScript that declared the variables you are talking about. Then you could just enumerate the appropriate variable in the JavaScript inside the page to populate the SRC attribute of the IMG tag.
The more powerful way to do it would be to use a server side scripting language such as ASP or PHP to select and output the appropriate image based on a query string. Then you could simply point the SRC attribute of the IMG tag to the ASP or PHP script with the query string set for that page. This is the more elegant solution, and is the way I would choose to do it.
Let me know which way you would prefer and I can give you specific code examples and article references.
Jason Jystad
Cito Technologies
www.citotech.net
>------------------------------------------------<
"Luckily," he went on, "you have come to exactly the right place with your interesting problem, for there is no such word as 'impossible' in my dictionary. In fact," he added, brandishing the abused book, "everything between 'herring' and 'marmalade' seems to be missing."
-- Dirk Gently (Douglas Adams)
>------------------------------------------------<
|
|
|
|
|
Take a look at this article
http://javascript.about.com/library/weekly/aa102901a.htm
it talks about external javascript files, referanced like so:
another approach would be traditional include files. but I would try the external javascript first.
Here are a couple of links to some info on SSI in general. If you decide to try includes, you can give them a read.
http://mkruse.netexpress.net/info/ssi/
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html
hope that helps. if you decide you want to try the dynamic version using asp/php let me know and I'll post a code snippit.
Jason Jystad
Cito Technologies
www.citotech.net
>------------------------------------------------<
"Luckily," he went on, "you have come to exactly the right place with your interesting problem, for there is no such word as 'impossible' in my dictionary. In fact," he added, brandishing the abused book, "everything between 'herring' and 'marmalade' seems to be missing."
-- Dirk Gently (Douglas Adams)
>------------------------------------------------<
|
|
|
|
|
you can link to an external javascript file by using the attribute in a script tag src="background.js" by incuding that attribute you can interact with the JS file withing the script tag.
-Steven
Visit Ltpb.8m.com
Surf the web faster than ever:
http://www.404Browser.com
|
|
|
|
|
Ok, I have my html page called test.htm, my external javascript file called images.js and one of my images called banner_02.gif. They are all in the same directory.
This is my html code (don't mind the rest, just my variable imSRC = banner;:
function makeIm() {
NS4=(document.layers);
IE4=(document.all);
scaleWidth = true;
scaleHeight = true;
imSRC = banner;
if (NS4) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
if (NS4) onresize = reDo;
if (IE4) onresize = reDoIE;
function reDoIE(){
imBG.width = document.body.clientWidth;
imBG.height = document.body.clientHeight;}
winWid = (NS4) ? innerWidth : document.body.clientWidth;
winHgt = (NS4) ? innerHeight : document.body.clientHeight;
imStr = "<div id=elBGim"
+ " style='position:absolute;left ;top ;z-index:-1'>"
+ "<img name='imBG' border='0' src="+imSRC;
if (scaleWidth) imStr += " width="+winWid;
if (scaleHeight) imStr += " height="+winHgt;
imStr += "></div>";
document.write(imStr);}
makeIm();
------------------------
Now, I aren't sure how I should write images.js
This is all I have:
var banner = "banner_02.gif";
--------------------------
I know that test.htm is reaching images.js, because when I remove script src="images.js" I get an error with the variable banner.
How do I write the external javascript file?
Regards
JRoberts
|
|
|
|
|
The images.js file should be somethign like this:
function makeIm() {
NS4=(document.layers);
IE4=(document.all);
scaleWidth = true;
scaleHeight = true;
imSRC = banner;
if (NS4) {
origWidth = innerWidth;
origHeight = innerHeight;}
function reDo() {
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload();}
if (NS4) onresize = reDo;
if (IE4) onresize = reDoIE;
function reDoIE(){
imBG.width = document.body.clientWidth;
imBG.height = document.body.clientHeight;}
winWid = (NS4) ? innerWidth : document.body.clientWidth;
winHgt = (NS4) ? innerHeight : document.body.clientHeight;
imStr = "
+ " style='position:absolute;left ;top ;z-index:-1'>"
+ "
";
document.write(imStr);}
makeIm();
in test.html it should have:
var banner = "banner_02.gif";
Visit Ltpb.8m.com
Looking for more tutorials? Ltpb.8m.com/Tutorial
3D Image Library: Ltpb.8m.com/Image
Surf the web faster than ever:
http://www.404Browser.com
|
|
|
|
|
How to transform this using XSL ?
<TAGNAMES>
<TAGNAME a="1" b="2">
<TAGNAME a="1" b="3">
.
.
<TAGNAME a="2" b="4">
<TAGNAME a="2" b="5">
.
.
<TAGNAMES>
to the form
<P>
<X x="1">
<Y="2">
<Y="3">
.
.
</X>
<X x="2">
<Y="4">
<Y="5">
.
.
</X>
</P>
Thank you!
|
|
|
|
|
Actually this isn't valid XML. No closing of the TAGNAME tags.
I'm affraid what you are trying to do may not be possible in a general case
. If the A values are from a known set you can probably do it, by doing an xsl:if and a xsl:foreach for each possible value
<br />
<xls:if select="TAGNAME[@x='1']"> <br />
<xsl:foreach select="TAGNAME[@1='1']"> <br />
...<br />
<br />
The absence of genuinely variable variables in XSL otherwise rather screws you up.
|
|
|
|
|
jenitennison.com is very helpful. It shows how to group XML elements based on keys.
|
|
|
|
|
I am trying to generate an orderID #, using the format YYYYMMDDhhmmXXX, where Y=year, M=month, D=day, h=hour, m=minute, XXX=sequential number 000-999(incrementing by 1 each order).
I havd no problem formatting the date part of this string, but when I retrieve the highest/most recent number, trim off the last 3 digits, add 1, then try to append the new dateformat with the new incremented 3 digit number, the 0's before the last digit get dropped and leave me with less digits than i need...
Did that make sense??
so when i need 200110251030001, i get 2001102510301
If you understand what i am asking and can help, please do!!!
chris tranchina
web developer
atlanta, ga
|
|
|
|
|
If you're storing the date as a string, you can write a little function to insert 1 or 2 zeros based on its numeric value (i.e., insert two zeros if the number < 10, one if it's < 100, no zeros if it's >= 100). Then just append that to your date string.
Jon Sagara
I can't think of anything original to say.
|
|
|
|
|
if you are using ASP this will work...
try it out
unique_id= Year(now()) & padzero(month(now())) & _
padzero(day(now())) & padzero(hour(now())) & _
padzero(minute(now())) & padzero(second(now()))
and you can write a padzero function as follows
function padzero(s)
if(len(s)<2) then s="0" & s
padzero=s
end function
Hope that helped
Nish
|
|
|
|
|
is there an html, xtml, javascript or something that has a date object for user input. I want to do something like this:
Birth Date:
But of course that doesn't work because there is no date input type that I know if.
|
|
|
|
|
How can i run an exe file installed on client pc from ASP requesed by user ?????
I know that this is 100% possible bcoz from hotmail page user can able to see his online frient of msn messanger and if he duble click on it messanger box is invoked from yr web page... So i want to do excetly the same thing......
Thanks.
|
|
|
|
|
Actually they use vbscript. The vbscript invokes the MSN activex object and executes it in the webpage.
|
|
|
|
|
I am agree with yr concept they r exacetly doing the same thing but if i would like to do thins thing in my system the how can i achive this kind of feature is ther any idea...
Thanks.
|
|
|
|
|
I have a list of data that is inserted to a text file in this fashion:
data.txt:
**********
sean
bob
sally
joe
smith
**********
When I add to this list, it adds new names to the bottom of the list. I use the writeline command to write. Is there a way of added to the top of the list instead of the bottom of the list.
Any help would be great!
Thanks!
|
|
|
|
|
First read the existing text file (ReadAll if you're using the FileSystemObject), store it in a variable, then open the file ForWriting (not appending), write the line you want at the top of the file, then write your variable holding the old text.
You might be able to come up with something better if you dig around in the FileSystemObject documentation.
Andy Gaskell, MCSD
|
|
|
|
|
How would you include multiple lines as one variable and keep the same format as before (line spacing)?
Would I need to use a DO WHILE Loop? I believe this is the better way right? But I want to keep the same format...
Advice...? Thanks!
|
|
|
|
|
First thing that comes to my mind is that you need to count the lines in the file. Redim an array to the size of the line count and read the line items into their appropriate array positions. Clear the file, write your new first line and then write the array contents to the file line by line. Sounds like it would work to me!
You could also probably just create a new file, write your new line, open the old file and read it line by line and then write each line to the new file as you're reading it from the old one. There's nothing stopping you from having multiple instances of the file system object. If you need the same file name you could then delete the old file and rename the new one.
Good luck!
Jon
|
|
|
|
|
Actually the ReadAll method pulls the whole contents of the file into a single string, with the lines separated by newline characters. This means you can just write the string back out to the file and all the lines will be intact. You do not have to do anything To have it work.
You do need to make sure that you use WriteLn to write out your new entry, that way a newline character is inserted at the end. If you just Write it out you won't get a newline character.
Jason Jystad
Cito Technologies
www.citotech.net
>------------------------------------------------<
"Luckily," he went on, "you have come to exactly the right place with your interesting problem, for there is no such word as 'impossible' in my dictionary. In fact," he added, brandishing the abused book, "everything between 'herring' and 'marmalade' seems to be missing."
-- Dirk Gently (Douglas Adams)
>------------------------------------------------<
|
|
|
|
|
I am new to both ActiveX and Java but have a good handle on C++, VB etc...
I'm looking to build a simple web based application that would run within a browser (IE5). I need it to retrieve and modify files from an FTP server. Which would be the best technology to use? Which is easier? Does one have better support for an FTP interface? Are there any other technologies out there that would be better to use?
Thanks in advance for any advice.
Dave
|
|
|
|
|
You could just use straight VB or C++ (COM, basically) as a middle tier and let the middle tier components on the web server handle the FTP stuff. That way you could target more browsers, and your users wouldn't have to download an ActiveX control.
Otherwise an ActiveX control should work fine.
Andy Gaskell, MCSD
|
|
|
|
|
I would like to use a middle tier, but the web servers I am targeting for this do not allow any sort of scripting. The only solution I could come up with was to use Java or ActiveX running on the client side.
Do you know if I will run into any problems getting the applet or control to open ports and communicate through FTP. Are there built in security "features" that prevent this?
Are there any examples of an applet or control out there using FTP?
Thanks again for your help.
|
|
|
|
|
I'm not sure about applets... (I'm not a Java guy, but I'm pretty sure Applets are dead)
As for the ActiveX side of things you might want to look into the Internet Transfer Control. You could write your own control in VB and use the Internet Transfer Control within your control. I'm pretty sure there are API calls for most of the things the Internet Transfter Control does, so you could also write a control to use the API calls instead.
If you can connect via FTP servers with a normal FTP client there is no reason why the Internet Transfer Control would not work.
Here's a couple links that'll hopefully help you out (both open in new browsers).
http://www.planet-source-code.com/xq/ASP/txtCodeId.27216/lngWId.1/qx/vb/scripts/ShowCode.htm
http://www.google.com/search?hl=en&q=vb+ftp+control
Andy Gaskell, MCSD
|
|
|
|