Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript query

  • 28-04-2005 11:16AM
    #1
    Closed Accounts Posts: 4,655 ✭✭✭


    Just wondering what the following piece of code means

    
    var contPage = (location.search.substring(1))? location.search.substring(1) : 'sample.php';
    


Comments

  • Closed Accounts Posts: 36 Caixa


    As far as I can see, it sets contPage to the first element that comes after the ? in the url (example.html?value) and if there's no value, it defaults to sample.php. It could then be used in, say, a frame or iFrame to load in a page.

    Try doing a google for javascript query strings for a better explanation.


  • Registered Users, Registered Users 2 Posts: 1,268 ✭✭✭hostyle


    Caixa wrote:
    As far as I can see, it sets contPage to the first element that comes after the ? in the url (example.html?value) and if there's no value, it defaults to sample.php. It could then be used in, say, a frame or iFrame to load in a page.

    Not quite. Close though :) it sets contPage to the QUERY_STRING (all of it - not just the first value) in the URI if it exists. Otherwise it sets contPage to sample.php.

    I can explain it in detail if you want ...


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    following on from that, how do you discover the location of an item, in relation to the parent


    eg, I have an iframe called test, it is located on a page called example.php, and that is located in a frame called main, which is a frame of 100% to mask the URL


    What is the easiest way to determine its location like "top.frame.etc"


  • Registered Users, Registered Users 2 Posts: 1,268 ✭✭✭hostyle


    Ph3n0m wrote:
    following on from that, how do you discover the location of an item, in relation to the parent


    eg, I have an iframe called test, it is located on a page called example.php, and that is located in a frame called main, which is a frame of 100% to mask the URL


    What is the easiest way to determine its location like "top.frame.etc"

    Easiest way? Dunno. Sounds like it would be:
    top.frames['main'].document.getElementById('test') 
    

    provided you give your IFRAME an id matching its name ...


Advertisement