Forum Moderators: open
I know the code will go this way:
<iframe src="http://www.hiswebsite.com#section"></iframe>
However, in my case, I don't want to add the #section within the "src" tag. I just want to leave the url as it is.
Is there any way to make it jump without adding the "#section" at the end of the url?
Here's a work-around you can try. First you create an extra url on your domain. This new url is a full page iframe that uses the video page as the iframe source. Your main page then uses your new extra url as the iframe src instead of the external site.
Because that new url is on your domain, you can now call the scrollTo method onload, and use it to move your new page to the exact pixel position you need.
I am curious - what's the problem with using a fragment identifier (#) in the iframe's src url?
<body onload="window.scrollto(xposition,yposition)">
W3 Schools References: scrollTo() method [w3schools.com], onload event handler [w3schools.com]
You didn't answer the question, though - why avoid the fragement identifier at all, since there is already a nice section marked on the page you want to frame? I can't think of any downside and it's certainly a much easier and less problematic approach. There can be all kinds of trouble with pixel perfect positioning across different browsers.