strmiska
(strmiska)
May 3, 2015, 1:47pm
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
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
MrAddy
(Andrew)
May 3, 2015, 2:06pm
2
When you say link, you mean you want to show said website in the iframe ?
strmiska
(strmiska)
May 3, 2015, 2:18pm
3
yes, exactely - sorry, explained wrong
MrAddy
(Andrew)
May 3, 2015, 2:20pm
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
(strmiska)
May 3, 2015, 2:33pm
5
YES! it´s working - thanks for your time on sunday!
Oups, doesn’t work for me.
Do you trigger the script when button is clicked ?
Any Hype doc to share ?
MrAddy
(Andrew)
May 3, 2015, 8:07pm
7
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
(strmiska)
May 3, 2015, 8:40pm
9
funny - “google” doesn´t work here also - seemed to be protected.
MrAddy
(Andrew)
May 3, 2015, 9:00pm
10
What is the error message, is it something to do with X-Frame ?
It might be because google is HTTPS:// not HTTP://
MarkHunte
(Mark Hunte)
May 4, 2015, 10:36am
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
1 Like