I am using an javascript overlay in my site for my subscription form. I have loaded the code for overlay from net. It is in javascript. Now the thing is to trigger the overlay function using a link i need put some value under <a rel="">
.
more specifically, <a href="subscribe.php" rel="gb_page_center[450, 450]">click</a>
But i dont want to put a tag instead i want to link to the subscription page using javascript function. Now my problem is how or where do i put the value under 'rel' attribute in my javascript to get the same result???
I am using an javascript overlay in my site for my subscription form. I have loaded the code for overlay from net. It is in javascript. Now the thing is to trigger the overlay function using a link i need put some value under <a rel="">
.
more specifically, <a href="subscribe.php" rel="gb_page_center[450, 450]">click</a>
But i dont want to put a tag instead i want to link to the subscription page using javascript function. Now my problem is how or where do i put the value under 'rel' attribute in my javascript to get the same result???
Share Improve this question edited Jan 13, 2011 at 19:02 Pekka 450k148 gold badges986 silver badges1.1k bronze badges asked Jan 13, 2011 at 19:00 AnubhavAnubhav 792 silver badges9 bronze badges 2- 7 You should accept answers to your questions. – SLaks Commented Jan 13, 2011 at 19:04
-
So you want to place the
gb_page...
into therel
attribute programmatically? – Marnix Commented Jan 13, 2011 at 19:05
3 Answers
Reset to default 4Like this:
<a href="#;" onclick="alert(this.rel);return false;" rel="bob">A</a>
If you want to use plain JS without jQuery, try setAttribute: https://developer.mozilla/en/DOM/element.setAttribute
Give your tag an id attribute and then you can add:
document.getElementById("your_id").setAttribute("rel", "gb_page_center[450, 450]");
Using jQuery, this can be acplished quite cleanly by using the .attr() method:
$('a').attr('rel', 'gb_page_center[450, 450]');