PDA

View Full Version : targeting content to a specific div or iframe


ScottInTexas
06-20-2006, 03:57 AM
I know I have asked and handled this in the past, but I can't find the thread! I want the content of subsequent files to appear in a div I have set up for it.

The onClick is supposed to get the reuired file and put it in the place made for it.

I tried the iframe but if I don't need it I don't want it.

Thanks for the patience.



function menuOps(what){
document.write(what);
var myFrame = document.getElementById("dataWindow");
myFrame.src = what;
}

<div id="maincontent">
<div id="leftcolumn">
<ul>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)" onClick="menuOps('Contestants.html')">Contestants</li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="_blank">Dates</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="_blank">Contest Rules</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="_blank">The Contest</a></li>
</ul>
</div>
<div id="activewindow">
<iframe frameborder="0" name="dataWindow" backgroundColor="#f3f3f3"></iframe>
</div>
</div>

_Aerospace_Eng_
06-20-2006, 06:16 AM
Why do you not want to create seperate pages? Seriously quit being lazy you only have 4 links. There is the ajax solution: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm however the back button won't really work now. I would prefer the iframes of the ajax. IMO making seperate pages would be best since it is only 4 pages.

ScottInTexas
06-20-2006, 11:47 PM
I don't want to create a new page. I want the content to appear in the div I have made for it.

I tried the code you suggested but I get either an "Access Denied" error or "undefined" appears in the div.

The files I would be loading are located in the same folder as default.htm I have tried several strings to point to the file, but I'm just not getting the desired results. I swear I have used myDiv.src=myFile before, but that isn;t working.

Any other ideas?

_Aerospace_Eng_
06-21-2006, 12:07 AM
Just target the iframe
<div id="maincontent">
<div id="leftcolumn">
<ul>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)" target="theframe">Contestants</li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="theframe">Dates</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="theframe">Contest Rules</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem" target="theframe">The Contest</a></li>
</ul>
</div>
<div id="activewindow">
<iframe frameborder="0" name="theframe" id="theframe" backgroundColor="#f3f3f3"></iframe>
</div>
</div>

ScottInTexas
06-21-2006, 12:40 AM
I thought so. But it opens the page in a new browser as though I had said target="_blank".
I also tried target=document.theTarget with the same results.

<div id="leftcolumn">
<ul class="rqmenu">
<li><a href="contestants.html" target="document.theTarget">Contestants</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem">Dates</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem">Contest Rules</a></li>
<li onmouseover="HighLightMe(this)" onmouseout="LowLightMe(this)"><A href="MenuItem">The Contest</a></li>
</ul>
</div>
<div id="activewindow">
<iframe id="theTarget"></iframe>
</div>

_Aerospace_Eng_
06-21-2006, 02:07 AM
You need to give the iframe a name and target should be the name of the iframe. Look at the example I posted.

ScottInTexas
06-21-2006, 03:35 AM
Thank you thank you, thank you.