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
https://forums.phpfreaks.com/topic/228258-dynamic-javascript-based-on-anchors/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.