...

View Full Version : if src changes the style must change to



maxvanbakel
08-31-2011, 12:56 PM
Hi im a newbie to java so please don't laugh. And apologies in advance for my English.

When i open my page the src of the iframe is home.html. Home.html is empty and its in the way of the interface of my .swf file. My swf triggers the iframe to change into 50 different URL. So at the beginning the iframe should be gone. But whenever the src changes it should come back. I tried it by changing the height of the iframe. But nothing changes.

here is a preview http://boyswithbeards.net/xrc/pres/

I have something like this.




<iframe name="MoinkOriginal" id="MoinkOriginal" src="home.html" frameborder="0" scrolling="auto"></iframe>


<script type = "text/javascript">
var iframe = document.getElementById('MoinkOriginal');

if (src='home.html') {

var iframeElement = parent.document.getElementById('MoinkOriginal');
iframeElement.style.height = "0px"; // or use px
iframeElement.style.width = "500px"; // or use px
iframeElement.style.marginHeight = "-563px"; // or use px
iframeElement.style.marginLeft = "750px"; // or use px

}

else {

var iframeElement = parent.document.getElementById('MoinkOriginal');
iframeElement.style.height = "300px";
iframeElement.style.width = "500px";
iframeElement.style.marginHeight = "-563px"; // or use px
iframeElement.style.marginLeft = "750px"; // or use px
}

</script>


Thank you for helping me. Im stuck on this for days.

devnull69
08-31-2011, 01:37 PM
there is no margin-height CSS style ... it should be marginTop and/or marginBottom

maxvanbakel
08-31-2011, 01:51 PM
Oke I have changed that. But it is still not solving my problem to let the size of the iframe change as the src changes.

<script type = "text/javascript">


var iframe = document.getElementById('MoinkOriginal');

if (src='home.html') {


var iframeElement = parent.document.getElementById('MoinkOriginal');
iframeElement.style.height = "10px";
iframeElement.style.width = "500px";
iframeElement.style.marginTop = "-563px";
iframeElement.style.marginLeft = "750px";

}

else {

var iframeElement = parent.document.getElementById('MoinkOriginal');
iframeElement.style.height = "300px";
iframeElement.style.width = "500px";
iframeElement.style.marginTop = "-0px";
iframeElement.style.marginLeft = "750px";
}

</script>

devnull69
08-31-2011, 02:15 PM
One problem after the other

1. What is the variable "src" referring to? It's not mentioned anywhere
2. The compare operator is == and not =

I think this is what you really wanted to do


if(iframe.src == 'home.html')


3. You should alert iframe.src to make sure that it is just home.html and not a fully qualified URL instead (so maybe everything including http://www.........)

maxvanbakel
08-31-2011, 02:35 PM
Thankx devnull

the http:// worked. At this point when i enter the page he listens to the code top side of the code.

But i think the problem is that tha page only listens once to the code and doesnt reload and check what the src is

is this possible and is there a way that the code keeps looping in order to see what the src is?

maxvanbakel
08-31-2011, 03:08 PM
I think I need something that triggers the java again when the source reloads

now I have this:

var iframe = document.getElementById('MoinkOriginal');
iframe.onload = iframehandler;
function iframehandler()
{ etc.

but it still doesnt reload.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum