Results 1 to 4 of 4

Thread: loading a link on demand from another page (Iframe SSI 2)

  1. #1
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default loading a link on demand from another page (Iframe SSI 2)

    1) Script Title: Iframe SSI 2

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...iframessi2.htm

    3) Describe problem: This isnt a problem as such - I was just wondering if a page can be loaded into the iframe from a link that is on another page (of the same site) ?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If you're using PHP or another server side language you could just put it in the GET or other data for the top page. I think you know how that works, you pass the page name or a token that resolves to the page name and have the src attribute of the iframe written by the server.

    If no server side language is available, a javascript 'GET' can be used. The principle is the same only everything is done on the client side. If you need this, here's a simple javascript function to read a GET type query string:

    Code:
    function getQval(n) {
    	if(typeof n !== 'string'){
    		return null;
    	}
    	var r = new RegExp('[?&;]' + n + '=([^&;#]*)'), m = location.search;
    	return (m = r.exec(m))? unescape(m[1]) : null;
    }
    So if your link on the other page is href="index.htm?ipage=aboutus", on index.htm you could do like:

    Code:
    if (getQval('ipage') === 'aboutus'){
    	//do something here to make the src attribute of the iframe be "aboutus.htm"
    }
    In any case, as I think you know, the top page and the page in the iframe must be on the same domain. Your question implies that you don't know that the other page:

    I was just wondering if a page can be loaded into the iframe from a link that is on another page
    That other page, as long as it isn't the top page or the page in the iframe, it doesn't have to be on the same domain.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Thanks for that John - I'll have a better look at it in the morning but its close to 2am here and my brain is flagging.

    - All the pages are on the same domain BTW -
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I should note that doing this is sketchy. The iframe script doesn't support Opera. Depending upon the layout of the included page, there may be problems getting the iframe to resize properly in some or all of the browsers the script does support. You might be better off with a real server side include or AJAX. That's not to say those methods don't also have their drawbacks, I just feel more comfortable ironing those out than working with the iframe script, which hasn't ever been fully worked out in my opinion, and perhaps never really can be.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •