Home Technical Talk

HTML question.

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
I am looking for a way to create a link in a separate .html or .css file so I can paste the reference to that link in all my pages and then not have to worry when I need to update the link. Basically I want to create a variable in my webpage that loads in some specific text, is this possible?

Replies

  • Alemja
    Options
    Offline / Send Message
    Alemja hero character
    It might be possible, but you're going to need javascript to do it. I don't know javascript well enough to give you exactly what you want, but I can kind of give the logic.

    You need a class attached to something like so:
    <div class="insertLink"></div>
    
    You might be able to do this as well, but the javascript required might be a little different:
    <a class="insertLink"></a>
    
    and then have the javascript insert some html whenever it reads that class. If you search for "insert html using javascript" you might find the code you need.
  • equil
    Options
    Offline / Send Message
    you could do this with javascript. the usual way to go around doing this would be something like
    document.getElementById("YOURCONTAINER").innerHTML = "<b>WHATEVER</b>";
    
    since that runs user-side it might not be what you want though. you can also use php or some other server-side script, that's how people usually serve web pages with dynamic content. look into using include files, it's probably what you want.
Sign In or Register to comment.