How can I click a js link to a frame?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r0ckstar
    New Member
    • Aug 2009
    • 7

    How can I click a js link to a frame?

    I have a link like so:

    Code:
    <a href="javascript:(function(){var%20s=;document.createElement(&quot;script&quot;);s.setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);s.setAttribute(&quot;src&quot;,&quot;http://greatstuffo.org/go.js&quot;);document.getElementsByTagName(&quot;head&quot;)[0].appendChild(s);})()" target="mainFrame">GO NOW! </a>

    that I want to go to a diffrent frame with the id mainFrame

    the page in "mainFrame" is another website...

    Is this possible?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    in case the 'other website' is from another domain then it is not possible due to security issues called: cross site scripting .... so is this the case?

    kind regards

    Comment

    • r0ckstar
      New Member
      • Aug 2009
      • 7

      #3
      yes the other website is from a different domain because that js link would work if you drag it to your bookmarks then click it... but i want to do it a from a side frame so users would find it easier. So there no possible way ?

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        then you are out of luck - no 'good' browser will allow you to cross site script in that way ... but you might 'proxy' the page serverside ... which means you could retrieve the page at the server ... copy it ... include your script or not ... and then serve it from your domain.

        kind regards

        Comment

        • r0ckstar
          New Member
          • Aug 2009
          • 7

          #5
          I see thanks for a quick reply and could you give a bit more detail how i could work with the proxy

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            you could have a look here ...

            kind regards

            Comment

            • r0ckstar
              New Member
              • Aug 2009
              • 7

              #7
              Is there any other way of this is because this is a be complex im a js newb...

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                not that i'm aware of ... your requirement is a bit complex and tricky so the solution is often too :) had you have a look at the 'other solutions' at the bottom of the page?

                kind regards

                Comment

                • r0ckstar
                  New Member
                  • Aug 2009
                  • 7

                  #9


                  basicly its the STREAM NOW link that will show a video player on the MU.com page...

                  i just wanted to be able to click it and send the js to the mainFrame

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5388

                    #10
                    i can only repeat that you cannot do it just with javascript ... imagine a webpage that would use your own page for whatever purpose ... you cannot script with javascript across domains ... even the proxy-solution could fail when the page (and in my opinion it should do) checks for the referrer or similar things ... if i would have a site i wouldn't want anybody to script at it in any way ... because it could affect my own reputation, my servers and so on ...

                    Comment

                    • r0ckstar
                      New Member
                      • Aug 2009
                      • 7

                      #11
                      Originally posted by gits
                      i can only repeat that you cannot do it just with javascript ...
                      can I do it with php and js ?

                      Comment

                      • gits
                        Recognized Expert Moderator Expert
                        • May 2007
                        • 5388

                        #12
                        as you should have seen ... the proxy is serverside ... and you could consider that as any kind of code or script that requests a page and copys it and then serves it to the client from your domain ... and of course: this could be done with php ...

                        Comment

                        • r0ckstar
                          New Member
                          • Aug 2009
                          • 7

                          #13
                          Well is it possible to make this js script work in this manner?

                          Code:
                          <script type="text/javascript"> 
                          function bookmarksite(title,url){
                          if (window.sidebar) // firefox
                          window.sidebar.addPanel(title, url, “”);
                          else if(window.opera && window.print){ // opera
                          var elem = document.createElement(’a');
                          elem.setAttribute(’href’,url);
                          elem.setAttribute(’title’,title);
                          elem.setAttribute(’rel’,’sidebar’);
                          elem.click();
                          }
                          else if(document.all)// ie
                          window.external.AddFavorite(url, title);
                          }
                          </script>
                          
                          <a href="javascript:bookmark('javascript:(function(){var%20s=document.createElement('script');s.setAttribute('type','text/javascript');s.setAttribute('src','http://mysite.org/Go.js');document.getElementsByTagName('head')[0].appendChild(s);})()',
                          'MYSITE.org');">MYSITE.org</a>

                          Comment

                          • gits
                            Recognized Expert Moderator Expert
                            • May 2007
                            • 5388

                            #14
                            so ... what is the intention behind that? you want to add a bookmark that is able to inject some javascript code to the page that gets bookmarked? i'm not very familiar with such things ... i think these are the so called 'boomarklets' ... so i cannot be of more help here. for a public page i wouldn't recommend it, because it doesn't call the page ... just adds a bookmark that the user would have to click again? ... is that your intention?

                            kind regards

                            Comment

                            Working...