1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Running a Javascript Line Inside A Frame

Discussion in 'HTML & JavaScript' started by wehttam, Nov 11, 2009.

  1. wehttam

    wehttam Newbie

    Joined:
    Oct 15, 2008
    Messages:
    29
    Likes Received:
    0
    Hi,

    I really need some help, I created an index page with a frameset of two columns, one is the menu and the other column is a thirdparty page url.I have a link in the menu to run a javascript code that highlights all the members of a friendslist in the thirdparty website (I'm making an addon service to this website to help people invite their friends, instead of clicking one by one this javascript code automatically highlights all the members on that page),

    Anyway when I'm in the thirdparties member list page and run the javascript directly in the browsers address bar it works fine, but when I do it through frameset/menu by click on the link inside the menus frame it doesn't work, I've been scratching my head for hours and can't seem to come up with anything, this is what I'm using:


    index.html

    HTML:
    <html>
    
    <HEAD>
    <TITLE>» </TITLE>
    
    </HEAD>
    
    <frameset cols="20%,80%" border="0" scrolling="no" >
      <frame src="menu.html" name="menu" />
      <frame src="http://www.URLofThirdPartyForum.com/" name="main" />
    </frameset>
    
    </html>
    menu.html

    HTML:
    <HEAD>
    <TITLE>» </TITLE>
    
    <style type="text/css">
    body
    {
    background-color:#3b5998;
    }
    </style>
    
    
    </HEAD>
    
    <img src="fbpt.png"> 
    
    <br />On every new page of friends, <u><a href="javascript:elms=document.getElementById('friends').getElementsByTagName('li');for(var fid in elms){if(typeof elms[fid] === 'object'){fs.click(elms[fid]);}} " target="main">Click Here</a></u> to automatically highlight all your friends on that page. 
    
    © <script type="text/javascript">
    var theDate=new Date()
    document.write(theDate.getFullYear())
    </script>. All rights reserved.</font>
     
  2. showboytridin

    showboytridin Regular Member

    Joined:
    Sep 5, 2009
    Messages:
    348
    Likes Received:
    714
    Location:
    127.0.0.1
    Don 't know if I understood everything. But if you want to change one page using javascript code on other page (or frames for example), forget it. That 's impossible.
     
  3. wehttam

    wehttam Newbie

    Joined:
    Oct 15, 2008
    Messages:
    29
    Likes Received:
    0
    but how come it works when I execute the code via the browsers address bar while I'm in the forum members list page, eg:

    pasting this in the firefox url bar and hit enter:

    HTML:
    javascript:elms=document.getElementById('friends').getElementsByTagName('li');for(var fid in elms){if(typeof elms[fid] === 'object'){fs.click(elms[fid]);}} 
     
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    • Thanks Thanks x 1
  5. showboytridin

    showboytridin Regular Member

    Joined:
    Sep 5, 2009
    Messages:
    348
    Likes Received:
    714
    Location:
    127.0.0.1
    Because it 's on the same page. Never read this link before:

    Code:
    [URL="http://en.wikipedia.org/wiki/Same_origin_policy"]http://en.wikipedia.org/wiki/Same_origin_policy[/URL]
    But it 's very interesting (and logical!). If it were possible would be very critical.