Java iframes?

Soldato
Joined
22 Oct 2006
Posts
5,913
Hey all :)

Getting a bit stuck atm.

In my webpage I have a iframe displaying my blog, i'd like to have Java buttons to control the scrolling of the iframe.

If i have to rewrite the code for frame the in java then thats fine too.


Anyone know if this is possible?

Cheers
 
I think you mean JavaScript, not Java, they are very different languages. Is an iframe the best way of doing this? It's generally considered bad practise to use iframes these days, they are even blocked by some security policies.
 
Yea i agree, i'd rather not use them too,

and yea javascript not java :P been a long day,

I have my main page then in the middle i want to show my wordpress blog, but i want custom scrolling/radio buttons.
 
It might be worth having a look at jQuery. I can't totally envisage what you're trying to do but it could well let you achieve what you're after. A google for "jquery scroll" might give you what you're after.
 
I did a bit of looking for you. From what I can gather you may be able to use:

Code:
<iframe ... id="frameid".../>
...
<script type="text/javascript">
document.getElementById("frameid").scrollBy(x,y);
</script>

Not tried it before.
 
jscript stuff looks like what i need, as a quick idea of what i'm trying i drew it out in paint:

sitew.jpg


any ideas?

Yellow is my site already, the green is my wordpress site, and the buttons to the left are to control the scolling of the green section
 
Managed it in Javascript, unfortunately it only works if you can get some code into the page you want to include, and Chrome doesn't seem to like it - it's fine in IE8 and Firefox though.

Part 1 (to go in the page you will load from the iframe):
Code:
<script type="text/javascript">
var scrollspeed = 10;

var scrollstate = 0;
var scroll = 0;
function scrollUp() 
{
  scrollstate = -scrollspeed;
  move();
}
function scrollDown()
{
  scrollstate = scrollspeed;
  move();
}
function stopScroll()
{
  scrollstate = 0;
}

function move()
{
 
  if(scrollstate != 0)
  {
    window.scrollBy(0, scrollstate);
	scroll = setTimeout("move();", 32);
	return 0;
  }
  else
  {
	clearInterval(scroll);
	return 0;
  }
}



</script>

Part 2:
To go on the page that has the iframe on it:

Code:
<script type="text/javascript">
function scrollUp()
{
	document.getElementById('theframe').src="javascript:scrollUp()";
}
function scrollDown()
{
	document.getElementById('theframe').src="javascript:scrollDown()";
}

function stopScroll()
{
	document.getElementById('theframe').src="javascript:stopScroll()";
}
</script>

<iframe id="theframe" src="includethis.htm"></iframe>

<form>
<input type="button" onmousedown="scrollUp();" onmouseup="stopScroll();">^</input><br/>
<input type="button" onmousedown="scrollDown();"onMouseup="stopScroll();">V</input><br/>
</form>

Edit: of course there's a good likelihood you could just shove all that javascript I used into the src of the iframe, actually.
 
Okay i've set it up with what you've said and i've had no luck geting it to work.

I've used a test page thats set up as "www.itswarren.com/test.htm"

and the page inthe iframe is: "www.itswarren.com/blog/#"

I've added the radio buttom as per your code at the bottom and tested in IE8 and nothing yet.

Edit: Noticed i spelt something wrong. Its working in IE8 now, but not the latest FF beta.
 
Last edited:
Okay, I've not really managed to see what the real problem is - nor have I managed to get the code to work at all whilst looking at your site! Seems to work fine on my much simpler page. I can only really advise putting the scripts in the heads of the pages and see if that helps.
 
Back
Top Bottom