473,769 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open links in parent window ?

77 New Member
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)

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function loadinparent(url){
  3.     self.opener.location = url;
  4.  
  5.     }
  6.  
  7. </SCRIPT>
link in child must be

Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:loadinparent('http://www.google.com.au', true);">Google</a>
  2.  
Nov 4 '07 #1
6 2257
gits
5,390 Recognized Expert Moderator Expert
hi ...

you may use a function like the following:

Expand|Select|Wrap|Line Numbers
  1. function adapt_links() {
  2.     var links = document.getElementsByTagName('a');
  3.  
  4.     for (var i = 0; i < links.length; i++) {
  5.         var link = links[i];
  6.  
  7.         link.href = 'javascript:loadinparent("' + link.href + ', true")';
  8.     }
  9. }
call that onload of your popup-page ...

kind regards
Nov 4 '07 #2
Inny
77 New Member
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 :)
Nov 4 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ... no problem :) in case you have more questions, post back to the forum anytime ...

kind regards
Nov 4 '07 #4
Inny
77 New Member
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!

Expand|Select|Wrap|Line Numbers
  1. <table width="83%" td align="center" cellspacing="0" id="submenu">
  2. <tr>
  3. <td align=left>
  4.  
  5. <table width="100%" height="40px" border="0" cellspacing="0" cellpadding="0">
  6. <tr>
  7. <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>
  8. </font>
  9. </td></tr></table></td></tr></table>
  10. <script language="javascript" type="text/javascript">
  11. <!--
  12. if(self.location.href.match('http://herproom.5.forumer.com/index.php?&act=Search&CODE=getactive')){
  13. actm = document.getElementById('activetomar');
  14. actm.innerHTML += "<table class='tableborder'>Active Topics Removed</table>"
  15. }
  16. else {
  17. document.write("<iframe name='activetopmarq' src='http://herproom.5.forumer.com/index.php?&act=Search&CODE=getactive' style='display:none;' onload='latemarqHarvest()'></iframe>");
  18. //-->
  19. function latemarqHarvest()
  20. {
  21. martab = window.frames["activetopmarq"].document.getElementsByTagName("table");
  22. for(var i = 0; i < martab.length; i++){
  23. if(martab[i].className == "tablebasic" && martab[i].parentNode.className == "tableborder"){
  24. tabdiv = martab[i].innerHTML
  25. goingNav(tabdiv)
  26. }
  27. }
  28. }
  29. function goingNav(tabdiv)
  30. {
  31. actm = document.getElementById('activetomar');
  32. actm.innerHTML += "<table class='tableborder'>" + tabdiv + "</table>";
  33. }
  34. }
  35. //-->
  36. </script>
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2">
  2. function extractlinks(){
  3. var links=document.all.tags("A")
  4. var total=links.length
  5. var win2=window.open("","","menubar,scrollbars")
  6. win2.document.writeln('<link rel="stylesheet" href="http://www.fileden.com/files/2006/9/25/238265/default%20skin.txt" type="text/css">')
  7. win2.document.write("<h2>Total Links="+total+"</h2><br>")
  8. for (i=0;i<total-1;i++){
  9. win2.document.write(links[i].outerHTML+"<br>")
  10.  
  11. }
  12. }
  13. //-->
  14. </script>
  15. <button onClick="extractlinks()">Extract Links</button>
  16.  
  17.  
Nov 5 '07 #5
Inny
77 New Member
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!
Nov 6 '07 #6
gits
5,390 Recognized Expert Moderator Expert
hi ...

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

kind regards
Nov 6 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1878
by: kelli | last post by:
I am using an iframe to feed an RSS but when i click on the link on the iframe it opens the link on the iframe instead of opening it on the parent window or a new window.. the code is in php.. its something like this.. $item->source = $SERVER_URL; how can i make the links open in a new window or the parent window and not on the iframe .. Thanks Kelli...
10
11240
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#" onClick="window.open('/cgi-bin/displayimage.cgi?/store/demo/image.jpg&YOUR+PRODUCT%27<b>S+NAME+GOES', 'fullimage', 'WIDTH=420,HEIGHT=405,status=0')"> The original window should not reload, but is, and I have tested it with both version 4.72 and 7.02, and they both do it. IE does not do it....
2
19241
by: Robert Degen | last post by:
Hello, I got a little problem. Seems very simple: * I want to open a popup window * Popup-window uses data from its father window. BUT a parent.window does NOT point to the real parents window. Alerting parent.window.location.href shows me, I'm at the wrong window location.
1
2803
by: kambakht | last post by:
I am using an iframe in my index.aspx thus all the webforms in application navigate in this iframe. While main appication links are present on the top of page above iframe, in main window. These links have target=myiFrame, thus opening respective pages in iFrame. I have put the session timeout period on each page so if some user remains inactive for 10 minutes (all webforms in iframe), he will be redirected to login.aspx page through...
1
8112
by: kambakht | last post by:
I am using an iframe in my index.aspx thus all the webforms in application navigate in this iframe. While main appication links are present on the top of page above iframe, in main window. These links have target=myiFrame, thus opening respective pages in iFrame. I have put the session timeout period on each page so if some user remains inactive for 10 minutes (all webforms in iframe), he will be redirected to login.aspx page through...
3
3493
by: rick2910 | last post by:
Hello, I have a problem with a popup. In this popup (child) are several links. I want these links to open in A NEW parent window. Code: <a href="javascript:;" onclick="opener.location.href='http://www.test.com/'">Link name</a>
6
18225
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF files are in the same web server, other are in a remote location. Any help will be appreciated.
3
2608
tusovka
by: tusovka | last post by:
I have a php function that creates different links to a particular column in my <table>. The links work great, one problem though. Say your on the main page and you click one of the links that were generated. First, a new window opens (_blank) and address of the link is executed. So for the first click everything is great. But if you go back to the main page and clink on a different link, it will just load a new page in the child window. ...
0
9420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7401
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.