[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I set the left and top of a document inside a frame

Posted on 2006-05-26
10
Medium Priority
?
161 Views
Last Modified: 2010-04-09
Hello

I have an iframe tag inside my document, in this frame I load another web page. I want that this page in my frame automatically scrolls to a certain position, so the user don't see the top of that page, just the important area.

Is this possible?

Thanks
0
Comment
Question by:rettiseert
  • 4
  • 4
  • 2
10 Comments
 
LVL 12

Assisted Solution

by:jessegivy
jessegivy earned 400 total points
ID: 16771321
<body onload="document.getElementById("anc").click();">
This is the content that appears above the area you want the iFrame document to be positioned
<a name="spot"></a>
This is the content that you want them to see
<a href="#spot" id="anc"></a>

...might seem a little ugly, but avoids the browser detection that would be required with setting top and left.  The second anchor tag can really go anywhere inside the body, doesn't have to be at the end.

Cheers,

Jesse
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 16771347
...of course this would have to appear inside the actual document that's contained within the iFrame, in other words, it's src.

If you're using this page in other areas, then you can add the anchors, and then set the iFrame's onLoad event procedure from the parent page within the onLoad of the parent

Let me know if ya have any questions.
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 16771774
just load the url with the hash code:  <iframe src="mypage.html#mysection">
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 16771783
> with the hash code
lol, nice lapsus... i meant the hash value
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 16772597
Duh, my brain's a bit like swiss cheese right now, thanks!
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 16772643
=)
0
 
LVL 13

Author Comment

by:rettiseert
ID: 16786288
Hi

and thanks for your suggestions

I cant use  <iframe src="mypage.html#mysection"> 'cos mypage.htm is not mypage, its another page in another websithe and I have no control overt its source

and... can I access to the DOM of a document inside an iframe?
0
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 800 total points
ID: 16786688
No, you cannot use javascript if the page is on a different domain, that's called cross-domain scripting.
Look at the page to see if it uses any "id".  All id's are anchors.
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 16790715
I'm not real sure about the copyright issues involved with using a page that doesn't belong to you embeded within your site?

I would suggest a link instead, and you should get permission from the company before linking your site to theirs, they might be okay with the iFrame usage?

...an interesting question at any rate.  I would wager there probably is a way to access the DOM of another domain, I guess it just depends on weather you wanna be called a programmer, or a hacker.  ;)

Is this dynamic content that your displaying from someone elses site?  You could make your own page with the content you desire, though that's probly not any better for copyright concerns.  Personally I wouldn't be real comfortable having embedded content outside my control like that within one of my sites, if they change it or move it, you're SOL.

Cheers,

Jesse
0
 
LVL 13

Author Comment

by:rettiseert
ID: 16874943
Hi, and thanks to all, well, yes, those sites are not mine, but I don't think its a copyright problem to have'em on my site.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question