Member Avatar for Member #941443

(skip to 2nd paragraph if you don't want backstory deets)
I made a mistake guys...A friend is working on this big project and wanted me to help with his site since I sitebuild and the works. I'm used to manually creating sites myself, but he needed to be able to add content after I finished, so I needed a host/site editor that would allow him to do that. I chose wix because it seemed pretty good...It was ok until he started making very code-heavy demands. I was able to find rediculous workarounds to a lot of the problems with it...but the probably easiest thing is something I can't figure out...

A link in wix's html widget only seems to open in the box frame where the code is, or open another tab. I can't have the actual page it's on change. I've tried both target=blank and target=self but neither works. I'm at a loss...I feel really bad about messing this up by picking wix..

Dani AI

Generated

Short recap and the reason this happened: was embedding raw HTML into Wix's HTML widget, and the widget runs your code inside a sandboxed iframe — so links inside it are confined to that frame (or will open a new tab), not the whole browser tab. This is how Wix isolates embedded code from the rest of the page. (dev.wix.com)

Why target values alone didn't help: anchor target values act against the current browsing context. _self replaces the iframe content, _blank opens a new tab, and _top would replace the whole tab — but only when the iframe is permitted to navigate the top context. A sandboxed iframe or browser framebusting protections can block that. In short: the platform or browser is likely preventing your link from breaking out. (developer.mozilla.org)

Practical workaround (if you can edit the parent page with Velo / Dev Mode): send a message from the iframe to the Wix page and have the parent do the navigation. Use window.postMessage inside the HTML widget and $w(...).onMessage() plus wixLocation.to() in your page code. Example pattern:

/* inside the HTML widget (iframe) */
window.parent.postMessage({ type: 'navigate', url: 'https://example.com' }, 'https://your-site.com');

/* in your Wix page code (Velo) */
import wixLocation from 'wix-location';
$w.onReady(() => {
  $w('#html1').onMessage(event => {
    if (event.data?.type === 'navigate') wixLocation.to(event.data.url);
  });
});

This uses a secure message channel rather than trying to reach top directly. Always specify and check origins when using postMessage. (developer.mozilla.org)

If you cannot run page code on the parent side, there is no reliable way to force the outer tab to change from inside Wix's HTML widget because of the iframe/sandbox rules; the remaining choices are opening a new tab, placing the link outside the widget, or rebuilding that content as a normal Wix page. (dev.wix.com)

Recommended Answers

All 6 Replies

Member Avatar for Member #949455

A link in wix's html widget only seems to open in the box frame where the code is, or open another tab. I can't have the actual page it's on change. I've tried both target=blank and target=self but neither works. I'm at a loss...I feel really bad about messing this up by picking wix..

I don't understand your issue at all. You want open a new window or in the same window?

Try these and pick the one that is closest to your issue:

<body>
<!--example 1-->
<a href="" target="_top">link1</a>
<iframe src="" name="iframe1"></iframe>
<!--example 2-->
<a href="" target="_parent">Link2</a>
<iframe src="" name="iframe2"></iframe>
<!--example 3-->
<base href="" target="_blank">Link3</a>
<iframe src="" name="iframe3"></iframe>
</body>

If none of the above. Then you need to post a code snippet of the issue you are having.

Member Avatar for Member #941443
<a href="scatterset.com/#!videoscroller/c1cdw" target=_blank>
    <img src="http://www.quackit.com/pix/milford_sound/milford_sound_t.jpg" border="2" style="border:2px solid black;max-width:50%;" alt="Photo of Milford Sound in New Zealand!" />
    </a>

A simple image html. It's probably just wix destroying my life, but I wanted to be sure. I've tried target=_blank, and target =_self. Both of which are the 2 extremes. first opens a new tab, second opens the new page in the box it's contained and not the entire tab itself. I just want the current tab to be changed.

It sounds like that wix widget is an iframe on the page. Can you provide the URL so we can see the source code?

Member Avatar for Member #941443

Thanks for the help.

Member Avatar for Member #949455

Thanks for the help.

Did you follow the instructions here:

It's blank when I click the link you provide.

I think JorgeM is correct regarding about wix widget is an iframe.

I just want the current tab to be changed.

I'm not sure it's good idea to open an iframe within a iframe? I don't see that often.

You can try this:

http://www.trans4mind.com/personal_development/HTMLGuide/iframes3.htm

Member Avatar for Member #941443

Yea I figured it worked as an Iframe. Oh well. Thanks for the help guys!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.