-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Links with target="top" don't work #266
Comments
It looks like an |
I played with the window.addEventListener('DOMContentLoaded', (event) => {
const iframeDocument = document.querySelector('iframe').contentDocument;
iframeDocument.addEventListener('click', (event) => {
if (event.target.tagName === 'A') {
event.preventDefault();
iframeDocument.location.href = event.target.href;
}
});
}); |
WordPress is rendered in a sandboxed iframe that prevents top-level navigation. However, some links in wp-admin, such as the "activate plugin" link rendered after the plugin is uploaded, are rendered with target="_parent". It does not make sense to target the top frame in this context. What we really want is to target the WordPress iframe. This commit fixes that via a <script> tag that rewrites the `target` of all clicked A elements from _top and _parent to wordpress-playground. Related: #266
WordPress is rendered in a sandboxed iframe that prevents top-level navigation. However, some links in wp-admin, such as the "activate plugin" link rendered after the plugin is uploaded, are rendered with target="_parent". It does not make sense to target the top frame in this context. What we really want is to target the WordPress iframe. This commit fixes that via a <script> tag that rewrites the `target` of all clicked A elements from _top and _parent to wordpress-playground. 1. Upload a plugin in wp-admin 2. Click "Activate plugin" 3. Confirm it worked and there are no errors in devtools 4. Play with other wp-admin pages and confirm no previously working links are now broken Related: #266
WordPress is rendered in a sandboxed iframe that prevents top-level navigation. However, some links in wp-admin, such as the "activate plugin" link rendered after the plugin is uploaded, are rendered with target="_parent". It does not make sense to target the top frame in this context. What we really want is to target the WordPress iframe. This commit fixes that via a <script> tag that rewrites the `target` of all clicked A elements from _top and _parent to wordpress-playground. 1. Upload a plugin in wp-admin 2. Click "Activate plugin" 3. Confirm it worked and there are no errors in devtools 4. Play with other wp-admin pages and confirm no previously working links are now broken Related: #266
WordPress is rendered in a sandboxed iframe that prevents top-level navigation. However, some links in wp-admin, such as the "activate plugin" link rendered after the plugin is uploaded, are rendered with target="_parent". It does not make sense to target the top frame in this context. What we really want is to target the WordPress iframe. This commit fixes that via a <script> tag that rewrites the `target` of all clicked A elements from _top and _parent to wordpress-playground. ## Testing instructions 1. Upload a plugin in wp-admin 2. Click "Activate plugin" 3. Confirm it worked and there are no errors in devtools 4. Play with other wp-admin pages and confirm no previously working links are now broken Related: #266
Fixed in #684 |
Console error when clicking "Activate" after uploading plugin:
Unsure if it's important or not, but just notating it here in case it turns up later.
The text was updated successfully, but these errors were encountered: