SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and Frames question.

    Sorry but I had no idea how to word the subject. [img]images/smilies/FRlol.gif[/img] anyway, I'm using the following script to check if my php script is opened in it's parent frame. Works fine. Is there anyway to put an "or" clause in there so it will be happy when opened in a second frameset? I want to use a script in two different pprograms but still try to limit it's direct access.

    PHP Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- 
    Begin
    if (parent.location.href == self.location.href) {
    // change the url below to the url of the
    // frameset page...
    window.location.href 'index2.html';
    }
    //  End -->
    </script> 

  2. #2
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The || is what you use for "OR". For example:

    if ((condition1) || (condition2))
    {
    //execute this code
    }

    Does that help?

  3. #3
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So it's the same as PHP then?

  4. #4
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah. You'll find that JavaScript and PHP are very, very, very similar. Almost all of the Boolean statement stuff like &&, +=, ==, =, it's all the same as PHP.

    Something good to keep in mind is that the syntax of advanced languages is almost all the same.

  5. #5
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, looking at the above script I am using. Isn't it just checking to see if the page is loaded by itself and loading index2.html instead? If so, then if it is opened under another frame this should read false and not open index2.html.

  6. #6
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gregc
    Something good to keep in mind is that the syntax of advanced languages is almost all the same.
    Eh? You're saying that because PHP and JavaScript share boolean operator syntax, they are both "advanced"???!! That's a sound argument if ever I heard one.... NOT!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  7. #7
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jump,

    Yes, your script is looking if the current page is loaded without being encapsulated in a frameset. In that case it will redirect itself to page "index2.html" which hopefully would be a frameset which holds the current page inside it.

    If your page gets loaded by any other page than itself this script would do nothing.

  8. #8
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by M@rco
    Eh? You're saying that because PHP and JavaScript share boolean operator syntax, they are both "advanced"???!! That's a sound argument if ever I heard one.... NOT! [img]images/smilies/tongue.gif[/img]
    Don't mock me. Advanced languages like C++ and Java are similar to PHP and JavaScript in syntax as well, although they are much more complicated. All I was saying was, once you get into PHP and JavaScript, most of the other advanced programming languages are easier to understand because their syntax is essentially all the same.


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
  •