Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » need a code that opens up a website in an iframe, and scrolls down to it
Closed Thread
Old 06-12-2007, 11:58 AM   #1 (permalink)
ibexpiotr's Avatar
 
True Techie

Join Date: Nov 2003

Posts: 196

ibexpiotr is on a distinguished road

Send a message via AIM to ibexpiotr
Default need a code that opens up a website in an iframe, and scrolls down to it

ok. so i have this one page with a bunch of links on top, and an iframe, on the bottom of the page.
once i click on the link i want the page to be displayed in the iframe, and the page to be automaticly scrolled down to where the iframe starts.
ibexpiotr is offline  
Old 06-12-2007, 12:28 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: need a code that opens up a website in an iframe, and scrolls down to it

Hmm, how about...a simple link:
Code:
<a href="your link" target="your iframe" onclick="focusIframe();">Hello</a>
Then some JS (put this in the <head> or <body> area):
Code:
<script type="text/javascript">
  function focusIframe( ) {
    var theElement = document.getElementById( "your iframe id" );
    
    if ( document.all ) {
      // Internet Explorer
      theElement.document.body.focus( );
    } else {
      // Firefox
      theElement.contentDocument.body.focus( );
    }
  }
</script>
...with some credit due to the FF/IE differences here.

Just remember to set the id="your iframe id" attribute.

That might work, though it's pure speculation...
__________________
Vormund is offline  
Old 06-12-2007, 03:31 PM   #3 (permalink)
ibexpiotr's Avatar
 
True Techie

Join Date: Nov 2003

Posts: 196

ibexpiotr is on a distinguished road

Send a message via AIM to ibexpiotr
Default Re: need a code that opens up a website in an iframe, and scrolls down to it

thx. it works when i open it in firefox, but when i try in ie, a window pops up, saying something like, for security reasons, the content has been blocked.. and when i click the link, it opens up in a new window..

with firefox it works great,
ibexpiotr is offline  
Old 06-12-2007, 04:51 PM   #4 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: need a code that opens up a website in an iframe, and scrolls down to it

Interesting...always gotta leave it to IE to create trouble! I would think it'd be the javascript if anything, but since it opens in a new window, it's saying the target="" is bad?! That sounds very odd, hmm, maybe someone else will know how to get around that...

I'll try to play with it when I get home. :eek:
__________________
Vormund is offline  
Old 06-13-2007, 02:39 PM   #5 (permalink)
Yek
 
T.F's Resident Cool Guy...

Join Date: Aug 2006

Posts: 1,625

Yek is on a distinguished road

Send a message via AIM to Yek Send a message via MSN to Yek Send a message via Yahoo to Yek Send a message via Skype™ to Yek
Default Re: need a code that opens up a website in an iframe, and scrolls down to it

If you opening the file on your pc and it is not on a webserver it will ask to run ActiveX Control , this will dissapear when it is ran on a server ?

Am i right i guessing that this is the problem?
Yek is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On