Link from button into iframe

hi!
i ´ve a button and a html-widget (id=“frame”). i want to link a website into the widget by clicking the button.
just simple, i thought :slight_smile:
i tried:

var link = hypeDocument.getElementById("frame");
link.innerHTML = "http://www.website.com";

also

var link = hypeDocument.getElementById("frame");
link.location.href = "http://www.website.com";

also

var link = hypeDocument.getElementById("frame");
link.src = "http://www.website.com";

but unfortunately nothing is working. does anyone know the script?
thanx

When you say link, you mean you want to show said website in the iframe ?

yes, exactely - sorry, explained wrong

In this case, you can use JQuery and just add this:

var frame = $('#frame').find('iframe').attr('src', "http://www.website.com");

The reason it’s a little complex is that Hype wraps the iframe, without an ID, into a Div, so you need to access the iFrame via said div.

YES! it´s working - thanks for your time on sunday! :wink:

Oups, doesn’t work for me.
Do you trigger the script when button is clicked ?
Any Hype doc to share ?

clickToLoad.hype.zip (90.4 KB)

Thanks !
that’s exactly what I did but using google.com. It didm"t work. Then replaced with Tumult.com and work perfectly. I don"t really understand why but it works

funny - “google” doesn´t work here also - seemed to be protected.

What is the error message, is it something to do with X-Frame ?

It might be because google is HTTPS:// not HTTP://

I think that some sites like google protect their pages from opening in iFrames.

see X-Frame-Options

The initial reason for this protocol is as I understand it to prevent click - jacking

1 Like