Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

innerHTMl change property

Status
Not open for further replies.

Web151

Programmer
Oct 3, 2006
4
GB
Hi,
I need to apply a behaviour to my button graphic that does the following;
onClick, it sets a layer called 'frame' to visible, (no probs there, using show/hide) the layer initially has no content, its just -

<DIV ID="frame" STYLE="position:absolute; left:8px; top:9px; width:690px; height:420px; z-index:2">
</DIV>


at OnClick I want also to load an iframe into the layer. I used Dreamweaver change property behaviour, and used the innerHTML option for DIVs it provides. Tried to set it to insert the html that will load the iframe, like so;

MM_changeProp('frame','','innerHTML','<iframe src=\" width=\"685\" height=\"415\" SCROLLING=\"auto\" FRAMEBORDER=\"0\"></IFRAME>','DIV')

I am missing something somewhere :eek:|
 
what is the code for
MM_changeProp
you are assuming we use dreamweaver and know what this function does!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
sorry, here is the code used by the MM_changeProp parameter;

<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
var obj = MM_findObj(objName);
if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
//-->
</script>
 
1stly why are you using such a complicated function to do something simple? also i beleive you are incorrectly escaping the HTML you want to use... I've done a simple test that works fine, try this...
Code:
<html>
<head>
<script>
function changeme(myid,mycontent){
    document.getElementById(myid).innerHTML = mycontent;
}
</script>
</head>
<body >
<div id="mydiv"><a href="javascript:changeme('mydiv','<iframe src=\'[URL unfurl="true"]http://www.url_to_display_in_iframe.com\'[/URL] width=\'685\' height=\'415\' SCROLLING=\'auto\' FRAMEBORDER=\'2\'></IFRAME>');">Click here</a></div>
</body>
</html>

so therefore the line might work better using this...
Code:
onclick = "MM_changeProp('frame','','innerHTML','<iframe src=\'[URL unfurl="true"]http://www.url_to_display_in_iframe\'[/URL] width=\'685\' height=\'415\' SCROLLING=\'auto\' FRAMEBORDER=\'0\'></IFRAME>','DIV');"

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top