Hello - I'm a relative newbie when it comes to dynamic content, and can't figure out how to make this work. I"m writing a list of social bookmarking links so visitors to the site can bookmark any page on the site. I want this a piece of code to be re-used on all pages of the site, so i want to be able to pull in the current page URL into the href string.
For the URL, you could use $_SERVER['REQUEST_URI'].
For the TItle, I would assume that you are using a variable to specify the page title on each page (since I would assume you are using 1 header file that you are including on every page), so you can just output the variable you are using for the Title.
In JavaScript, the href is accessed using... yourvar=location.href You can pluck out the path and hash or query portions quite easily. The document <title> is, wait for it, yourvar=document.title
Thanks very much for responding - I understand the DOM references, just not sure how to write that into the HTML? can you please show me an example of how to use location.href?
You may use location.href with document.getElementById or other methods to dynamic change any element in DOM tree. For the next example look on this code:
<p id="example"> This is some content </p><br /> <button onclick="document.getElementById('example').innerText=location.href">Click me!</button>
I would presume that ... <script> var URLHERE,TITLEHERE,YOURSTRING; URLHERE=location.href; TITLEHERE=document.title; YOURSTRING="http://www.blinklist.com/index.php?action=Blink/addblink.php&Description=&Url="+URLHERE+"&Title="+TITLEHERE; </script> Is that it?