Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorerineallen
    • CommentTimeJul 31st 2008
     permalink
    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 example:
    http://www.blinklist.com/index.php?action=Blink/addblink.php&Description=&Url=URLHERE&Title=TITLEHERE"

    how can i get URLHERE to fill in the current page URL and TITLEHERE to be the page title?

    Any help would be greatly appreciated!

    Thanks!

    -Erin
    • CommentAuthordavist11
    • CommentTimeJul 31st 2008
     permalink
    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.
    • CommentAuthorgogogob
    • CommentTimeAug 2nd 2008
     permalink
    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
    • CommentAuthorErinAllen
    • CommentTimeAug 7th 2008
     permalink
    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?

    Thanks!
    • CommentAuthormichal
    • CommentTimeAug 7th 2008 edited
     permalink
    Hi
    for example:

    <button onclick="alert(location.href)">click me!</a>

    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>

    Sorry for my english ;-)
    • CommentAuthorgogogob
    • CommentTimeAug 8th 2008
     permalink
    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?
Add your comments
    Username Password
  • Format comments as (Help)