Jump to content

Dynamic Javascript based on anchors


PhilipK

Recommended Posts

Hello,

 

I'm new to using javascript and have mainly used it for page includes up to this point. I have an idea for a small script but am looking for some help on the structure.

 

I want to have a small piece of javascript, a small section of which, is changed based on the the url #anchor.

 

The #anchor would be passed into a php include as the id of the object the javascript would act on.

Link to comment
Share on other sites

To be more specific here is the code I have

 

window.onload = function() {

 

    // open a welcome message as soon as the window loads

    Shadowbox.open({

        content:    '<div id="welcome-msg">Welcome to my website!</div>',

        player:    "html",

        title:      "Welcome",

        height:    350,

        width:      350

    });

 

 

I want the id to equal what ever is in the anchor tag.

So #websites would make <div id="websites">

 

Thanks in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.