open links in parent window ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Inny
    New Member
    • Nov 2007
    • 77

    open links in parent window ?

    Hi Im looking for a way to open all links (in a child window) in the parent window
    instead. I want this to happen Automatically because links in my child are called from the parent but I cannot alter link targets.
    <base target="x">(in child head tags) dont work, though some will launch a new window.

    I found this code idea that does work (see below) but I have no way of assigning the 'loadinparent' attribute to my childwindow links. Can I do that with javascript?
    e.g.

    if getelementbytag name==(a)
    then (a) = ('this attribute')
    }

    what works (head of child)

    Code:
    <script>
    function loadinparent(url){
    	self.opener.location = url;
    	
    	}
    
    </SCRIPT>
    link in child must be

    Code:
    <a href="javascript:loadinparent('http://www.google.com.au', true);">Google</a>
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    you may use a function like the following:

    [CODE=javascript]function adapt_links() {
    var links = document.getEle mentsByTagName( 'a');

    for (var i = 0; i < links.length; i++) {
    var link = links[i];

    link.href = 'javascript:loa dinparent("' + link.href + ', true")';
    }
    }[/CODE]
    call that onload of your popup-page ...

    kind regards

    Comment

    • Inny
      New Member
      • Nov 2007
      • 77

      #3
      Thankyou So much freind, I've been struggling with this for days, I was unable to work out how to affect link elements.
      You've been a great Help, I really Appreciate it!
      Cheers from Australia :)

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ... no problem :) in case you have more questions, post back to the forum anytime ...

        kind regards

        Comment

        • Inny
          New Member
          • Nov 2007
          • 77

          #5
          Actually I do have another request :D this one may be a little difficult?

          I have discovered that guest cannot veiw active topics on my site (though they can search manually and read them) . Presently Im using a somewhat dodgy
          code to extract and display links from the active topics page for members
          (see below) and using it in combo with the adapt url code you helped with above.
          reason im doing it that way is that the extraction code is very slow, because it calls the links every pageload, so to speed the site up im using the code above , with the slow code below in a new window, so users dont suffer slow pageloads (they need open the popup only once).
          Now what I want to do is use another code (2nd below) with some modification,
          to allow guests a similar menu of active topics links (since the first code below is somehow blocked for them)
          This code (2nd below) will extract links from that specific page into another specific page but I want to define/host the page so I can use the adapt links/load in parent code above[if thats possible]
          unless you can find a better way to extract and display links than the ( first code below) ???
          I realise this is a very complicated and odd request that may not be possible, but it was just the (2nd code below) that gave me the idea.
          Thanks in advance!
          cheers from Australia!

          Code:
          <table width="83%" td align="center" cellspacing="0" id="submenu">
          <tr>
          <td align=left>
          
          <table width="100%" height="40px" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td class="row1" width="100%" height="40px"style="text-align:center"><marquee behavior=scroll direction=up scrollamount=4 onmouseover=this.stop() onmouseout=this.start() id="activetomar"></marquee></td>
          </font>
          </td></tr></table></td></tr></table>
          <script language="javascript" type="text/javascript">
          <!--
          if(self.location.href.match('http://herproom.5.forumer.com/index.php?&act=Search&CODE=getactive')){
          actm = document.getElementById('activetomar');
          actm.innerHTML += "<table class='tableborder'>Active Topics Removed</table>"
          }
          else {
          document.write("<iframe name='activetopmarq' src='http://herproom.5.forumer.com/index.php?&act=Search&CODE=getactive' style='display:none;' onload='latemarqHarvest()'></iframe>");
          //-->
          function latemarqHarvest()
          {
          martab = window.frames["activetopmarq"].document.getElementsByTagName("table");
          for(var i = 0; i < martab.length; i++){
          if(martab[i].className == "tablebasic" && martab[i].parentNode.className == "tableborder"){
          tabdiv = martab[i].innerHTML
          goingNav(tabdiv)
          }
          }
          }
          function goingNav(tabdiv)
          {
          actm = document.getElementById('activetomar');
          actm.innerHTML += "<table class='tableborder'>" + tabdiv + "</table>";
          }
          }
          //-->
          </script>
          Code:
          <script language="JavaScript1.2">
          function extractlinks(){
          var links=document.all.tags("A")
          var total=links.length
          var win2=window.open("","","menubar,scrollbars")
          win2.document.writeln('<link rel="stylesheet" href="http://www.fileden.com/files/2006/9/25/238265/default%20skin.txt" type="text/css">')
          win2.document.write("<h2>Total Links="+total+"</h2><br>")
          for (i=0;i<total-1;i++){
          win2.document.write(links[i].outerHTML+"<br>")
          
          }
          }
          //-->
          </script>
          <button onClick="extractlinks()">Extract Links</button>

          Comment

          • Inny
            New Member
            • Nov 2007
            • 77

            #6
            Sorry, Ignore the last post, I found a setting Id overlooked to allow guest to see the original code. LOL

            Thanks again so much for your help on this issue. This topic is Resolved!

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              hi ...

              glad to hear that :) ... post back to the forum anytime you have more questions ...

              kind regards

              Comment

              Working...