Is it possible iframe a source file from the server instead of a URL meaning instead of
---> Instead of
<iframe width='100%' height='100%' src='http://example.com/file.php' allowTransparency='yes' frameborder='no' scrolling='no' id='adminheader' > </iframe>
---> Load Server Side File
<iframe width='100%' height='100%' src='/home/username/public_html/header.php' allowTransparency='yes' frameborder='no' scrolling='no' id='adminheader' > </iframe>
The aim to load the header only as is and if possible to access it indirectly applying certain styles and scripts.
No, since iframes are rendered client-side. But I don't see why you couldn't just load them with URL.
<iframe src='http://example.com/header.php'>
Related
I am displaying some 3rd party banners inside an Iframe which are loading through javascript. Banners are showing inside iframe and links are openning to new window when I browse the url myself. Problem is when I am trying to advertise the url to different ptc sites. Basically this site show url inside iframe. so when my url which is itself an iframe loading inside another iframe, clicking not working. Below is my current code
<base target="_blank"> //in head section
<iframe sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads" src="<?php echo $_SESSION['ad_url'];?>" frameborder="0" id="pgl" name="pgl" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%" onmouseover="on_mouseover(this)" onmouseout="on_mouseout(this)"></iframe>
As i see the source of the page that embeds my iframe found below code
<iframe sandbox="allow-same-origin allow-scripts allow-forms" id="surfsite" name="surfsite" src="https://sitename.com/sitename.php?" width="100%" height="100%" frameborder="0" scrolling="yes"></iframe>
how can I make this working
I understand that an iframe is rendered by the browser engine
is there a way to render the full HTML on the server side and serve it to the front end?
I tried the PHP's file_get_contents() function and the srcdoc attribute for the iframe
This simply downloads the content of the page and makes it unusable
<?= file_get_contents('http://dns_blocked_by_isp.com'); ?>
And this renders a non-working iframe
<iframe srcdoc="<?= file_get_contents('http://dns_blocked_by_isp.com'); ?>"
frameborder=0 width=510 height=400 scrolling=no
allowfullscreen=allowfullscreen>
</iframe>
So am basically looking for an alternative of runat="server" in ASP.NET but for PHP if possible
Motivation:
My ISP blocked the DNS address where I get my iframe source from, but my server runs on a different region which means it can download the content just fine and the urls in the iframe has -cdn.com suffix which in turn is not blocked by the ISP
Thank you
To get around browser support issues, you'd probably be better off setting up a PHP proxy page (i.e. a script on your server that just fetches the remote page and serves the source directly as a page from your server), but I suspect that the issue you're running into is just that the " characters being returned from the remote page are breaking the srcdoc attribute. Let's say that the remote file looks like:
<p class="worldclass">Hello World</p>
Then your example would result in:
<iframe srcdoc="<p class="worldclass">Hello World</p>"
So the the value of srcdoc is just <p class=
You just need to escape the code appropriately:
<iframe srcdoc="<?= htmlspecialchars(file_get_contents('http://dns_blocked_by_isp.com')); ?>"
frameborder=0 width=510 height=400 scrolling=no
allowfullscreen=allowfullscreen>
</iframe>
I have one iframe and some link.
I wold like if I click a link it update the iframe.
echo"<iframe name='vidframe' width='100%' height='360px'
src='http://vidto.me/embed-3t83y76l81ml-640x360.html' frameborder='0' allowfullscreen>
</iframe>";
echo"<a id='kat' target='vidframe' href='http://vidto.me/embed-32j7qctooybv-640x360.html'>
load link2</a>";
I use this method but when I click the link it opens in new tab not in the iframe. What have I change to open the links in the iframe?
Your code is somewhat correct but your video url is broken. I changed the URL to a youtube video for testing it works fine:
<iframe name='vidframe' width='100%' height='360px'
src='https://www.youtube.com/embed/x_p0VGctlOk' frameborder='0' allowfullscreen>
</iframe>";
<a id='kat' target='vidframe' href='https://www.youtube.com/embed/HuQSWt-jj8k'>
load link2</a>";
if you want to load to the full of the video in the new page maybe you can use this
echo"<iframe name='vidframe' width='100%' height='360px'
src='http://vidto.me/embed-3t83y76l81ml-640x360.html' frameborder='0' allowfullscreen>
</iframe>";
echo"<a id='kat' target='_blank' href='http://vidto.me/embed-32j7qctooybv-640x360.html'>
load link2</a>";
I want to use Google vrview-web using this example: googlevrview
How can I set src attribute in iframe tag?
Below is the example given in the link:
<iframe width="100%" scrolling="yes" allowfullscreen src="https://storage.googleapis.com/vrview/examples/video/index.html?video=examples/video/congo_2048.mp4&is_stereo=true"></iframe>
Now I have to set my video URL in src like below:
<iframe width="100%" scrolling="yes" allowfullscreen src="<?php echo VIDEO_URL.$data["video"]; ?>&is_stereo=true"></iframe>
It does not display the video.
if I use below iframe tag:
<iframe width="100%" scrolling="yes" allowfullscreen src="https://storage.googleapis.com/vrview/examples/video/index.html?video=MY_VIDEO&is_stereo=true"></iframe>
Still, it prints this data in my page:
Output
Assuming that the VIDEO_URL hold this:
https://storage.googleapis.com/vrview/examples/video/index.html?video=
Your iframe can't just print the HTML. Please inspect your rendered HTML/DOM or iframe src value is proper and not broken.
Moreover it is required that your website, where the videos are, allows CORS. Cross origin resource sharing. Otherwise the Google's script won't load your video inside the iframe in VR mode.
As the title says.
If i embed a youtube video with this exact same code on the same site on 2 different cpanel servers - running equivalent PHP and apache. Difference is - One is SSL, one port80 HTTP.
Both UK servers.
HTTP will play, SSL site will give UMG error for restricted content.
An example of the embed generated HTML is
<iframe id="ytplayer" width="100%" height="100%" frameborder="0" src="http://www.youtube.com/embed/My0HQ0QkGLQ?autoplay=1&origin=http://example.co.uk" type="text/html">
Php page is called with the URI browse.php?url=http://www.youtube.com/watch?v=KyAyuZPNo2w&type=video Then stripvid() gets the embed ID.
Is there any way to load a page as HTTP inside a HTTPS frame? Both pages on the same domain.
UPDATE:: Okay so redirecting the video URL to a non-HTTP server to parse and return an iframe works. but thats HTTPS page -> HTTP iframe -> Youtube iframe .
There will be techies here who will go nuts at that amount of iframes... ah well. Come up with something better? ;)
Changing '&origin=https://example.com"' to http doesn't help.
else if($_GET['type']=="video"){
$yurl = stripvid($url);
if ($yurl!=$url){
echo '<link href="examplecss.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.animate-colors.js"></script>
<script type="text/javascript" src="pixeljs.php"></script></head><body onload="sizewindow()"><div id="ytplayerdiv" style="height:100%; width:100%">
<iframe id="ytplayer" type="text/html" style="height:100%; width:100%"
src="http://www.youtube.com/embed/'.$yurl.'?autoplay=1&origin=https://example.com"
frameborder="0"/>
</div>
</body></html>';
}