Link from button into iframe


(strmiska) #1

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


(Andrew) #2

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


(strmiska) #3

yes, exactely - sorry, explained wrong


(Andrew) #4

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.


(strmiska) #5

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


(kerguelen) #6

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


(Andrew) #7

clickToLoad.hype.zip (90.4 KB)


(kerguelen) #8

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


(strmiska) #9

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


(Andrew) #10

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


(Greg) #11

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


(Mark Hunte) #12

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