logo
 
Thread
# 21:
Div Content With Tags

start at begin start at end
Oldest Posts In Thread Are Shown First
Scroll down to view posts



maribo

I'm using this javascript code (which I found here!) to change the content of a DIv :

Starting with this:

<script type="text/javascript"><!--

function ReplaceContentInContainer(id,content) {
var container = document.getElementById(id);
container.innerHTML = content;
}

//--></script>

Then I call that function from within another function which is used to give the answer to some quiz question:

<script type="text/javascript"><!--

function Drep() // function that gives the answer

    content = 'The answer is <b>TV</b>. <a href="fiche.php?code=TV" rel="clearbox[width=720,,height=500,,dlinsame]">More info</a>';
    ReplaceContentInContainer('reponse',content);
    }

//--></script>

The content of the DIV changes, I can see the text and link, but...

The <rel> attribute of the <a href> won't work. When I click the link, it opens a new page instead of opening the clearbox window. I have copied/pasted the exact same code (<a href="fiche.php?code=TV" rel="clearbox[width=720,,height=500,,dlinsame]">More info</a>) into my page and then it works with the clearbox.

Anyone can help me?




info button




maribo

I found a workaround using onclick instead of rel, but I still don't get it why the rel won't work.




info button




avatar
WillBontrager
profile web

maribo, the rel attribute's purpose is to specify a relationship between the document containing the link the document being linked to. Browsers don't use the attribute, but spiders may.

See HTML rel Attribute at W3schools.

onclick is the correct attribute to use for what you have in mind.

Will




info button


Site Owners Talk forum

Put the button on your web site and link to this forum. Here is the code: