Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript query

Options
  • 28-04-2005 12:16pm
    #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 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 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