Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace Page Links on Popup Page With Javascript to Open in Main (Parent) Window
    primarykey
    data
    text
    <p>I have a popup player for my radio station website. The window has links to various other pages in my site, some of which are created dynamically by Wordpress widgets.</p> <p>I want the links to open in the parent window as most of the content isn't suitable for the small popup window.</p> <p>The approach I have taken is to use javascript to re-write the links as target="parent". This works (from the footer) with the following script.</p> <pre><code>&lt;script&gt; var aEls = document.getElementsByTagName('a'); for (var i = 0, aEl; aEl = aEls[i]; i++) { aEl.href = aEl.href.replace('target="_self"','target="_parent"'); } var imgEls = document.getElementsByTagName('img'); for (var i = 0, imgEl; imgEl = imgEls[i]; i++) { imgEl.src = imgEl.src.replace('target="_self"','target="_parent"'); } &lt;/script&gt; </code></pre> <p>However, this only works for static links on the page, and not those generated via my slider widget or another widget.</p> <p>Is there some place this needs to be included, or an adjustment able to be made to find and replace all links after that have been generated?</p> <p>Edit: To avoid confusion, I'll reiterate the requirement (my attempt was just that, an attempt). I need to re-write all the links, on load, of my popup page, to open in the main site (parent window).</p> <p>Edit2: While I seem to be able to substitute target="_parent" it's not having the desired effect. Perhaps I need to somehow use <a href="https://forums.digitalpoint.com/threads/how-to-open-a-link-on-a-parent-window.444624/" rel="nofollow noreferrer">window.opener</a>. Any ideas?</p> <p>Edit3: <a href="https://stackoverflow.com/questions/14618972/open-popup-click-link-open-in-parent-window-close-popup">This</a> works correctly. I think my find/replace is going to have to rebuild this function around the links somehow.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload