variable for hyperlink

I have a question about some HTML programming im doing and what kind of file I should create. <br />
<br />
I need to make a dynamic variable that makes a hyperlink. I need to have a text file which will contain an ip which is updated every day by another script. <br />
<br />
What I need is for a variable on each page, to assign it's self to an ip in the text file. Then, throughout the page, links will look as follows.<br />
<br />
a href = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"http://<variable ip>/a_page.txt"> a page </a><br />
<br />
This does not work as far as I know. So I would like to know some solution to store the variable from the text file and incorporate it into the links on the page. This will be much easier than changing the ip every time in each file about 20 links a piece. <br />
<br />
Thanks for your expert help :)<!--content-->you should read some serverside articles about file functions<!--content-->It can be done with a little JS trickery and a hidden iframe. <br />
<br />
First you need to define your links similiar to:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/# onclick="gotoDynLink()">Dynamic Link</a><br />
<br />
Second include something like this in your body:<br />
<br />
<iframe id="hiddenFrame" style="display:none" src=http://www.webdeveloper.com/forum/archive/index.php/"linkSrc.txt"></iframe><br />
<br />
Then up in the head area place something like:<br />
<br />
<script type="text/javascript"><br />
function gotoDynLink(){<br />
window.open(hiddenFrame.document.documentElement.innerText);<br />
}<br />
</script><br />
<br />
Finally create your text file.....<!--content-->Javascript is certainly NOT the right tool for the task.<br />
First, you do not need to update all your links: use relative URIs for the links within your document then the only variable you need to update is a BASE element definition in your header:<br />
<!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/struct/links.html#edef-BASE">http://www.w3.org/TR/html4/struct/links.html#edef-BASE</a><!-- m --><br />
<br />
If you would like to pull this definition from a single file use Server Side Includes:<br />
<!-- #Include virtual="ipfile.txt" --> (that is for Apache server - ASP/IIS syntax is similar)<br />
<br />
Where ipfile.txt contains the singe line of BASE declaration.<!--content-->actually the thing is I need it to be <!-- m --><a class="postlink" href="http://ipadress/whatever.">http://ipadress/whatever.</a><!-- m -->. />
<br />
b/c it is not locally hosted, the pages are to bring up data from somewhere else. but the ip address changes, thus to make the switch easier I need something like this. Consider it almost like a mirror. <br />
<br />
Don't worry I'm not using this to leech off of a site ;-) ... just something my friend and I are setting up.<br />
<br />
the problem with the post below mine is ... I still have to redefine all the ip addresses. (I appreciate the thought tho). What I need is something similar to this: <br />
<br />
//Declare variable for ip address<br />
ipAdd = GetIpFromTextfile()<br />
<br />
<a href = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"http://ipAdd/somefolder/somehtml.html> a link</a><br />
<br />
<a href = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/">http://www.webdeveloper.com/forum/archive/index.php/</a><!-- m -->"http://ipAdd/somefolder/somehtml.html> another link</a><br />
<br />
etc...<br />
I have too many links which is the reason why I would liek to do something like this. so instead of going through each HTML file, I can simply have my script change the .txt file and the links on each HTML page (keep in mind more than 10) will automatically change because the variable references the text file for the ip address. <br />
<br />
I don't mind changing the format of all the pages to .php or .dhtml or what have you. So keep that in mind if you reply. <br />
<br />
Thanks again :-)<!--content-->Does not change the validity of my answer.<!--content-->You're going to have to change the links one time regardless. After doing that you could change the function to:<br />
<br />
<script type="text/javascript"> <br />
function gotoDynLink(){ <br />
window.open("http://"+hiddenFrame.document.documentElement.innerText+"theRemainder of the string"); <br />
} <br />
</script><br />
<br />
and get what it appears you're asking for. Then if the address changes, it's just a matter of changing the text file from there on out.<!--content-->Thnx bear, I'll try it now and see if it works. Looks functional tho :)<br />
<br />
Ok .. here is what I ended up doing. I used javascript to open the window as bear showed me. However I made one change. I created a js file that looks like this:<br />
<br />
var site_ip = "###.###.###.###"<br />
<br />
then I used the <SCRIPT> operator on each page to include the site_ip.js file into each of the pages<br />
<br />
and references the variable when i used java script to open the window. <br />
<br />
Thanks for all your suggestions guys ;-)<!--content-->
 
Back
Top