A video website that I use has started to overlay an image on top of their content for users using an adblocker. For instance:
The image is overlaid using the following:
<div class="vid_lhs" id="website-name-message-users">
<img name="Map" usemap="#Map" style="max-width:100%" src="http://drop.website-name.com/website-name/images/website-name-abp-message.jpg">
</div>
And the video is hidden by setting display=none like so:
<div class="vid_lhs" id="ins_videodetail" style="display: none;">
....
<video class="videobase vsc-initialized" id="contentElement" width="100%" height="100%" preload="auto|metadata|none" playsinline="" webkit-playsinline="" src="http://website-nameod.bc.cdn.bitgravity.com/blah-blah.mp4" data-vscid="blah-blah" autoplay="" style="display: inline; object-fit: fill;"> </video>
....
</div>
This is easily bypassed using a simple script on the browser's web console:
$('#website-name-message-users').remove();
$('#ins_videodetail').show();
My question is: What are the different ways by which the website can identify that the DOM is being tampered, so that they can better protect their content? I ask because they seem to change the way this adblock-block is implemented every 2-3 days, which leads me to believe that they may be playing a (pointless?) cat-and-mouse-game with users like me...
Using Colorbox jquery plugin, I use the iFrame popup class to display websites. Usually this works just fine, except when the website I am opening has larger than normal width. If that happens, The website will show horizontal scrollbars.
Here is the Colorbox code I use in my <Head>
<script>
$(document).ready(function(){
$(".iframe").colorbox({iframe:true, width:"100%", height:"90%", scrolling: false});
</script>
Here is the link I use to open website
<a class="iframe" href="client.php?id=<?php echo $rows['id']; ?>&Client Name=<?php echo $rows['client_name'] ?>">
If the website that opens is pretty standard dimensions, there will be no scrollbars or anything which is perfect. If the website it opens is very wide, it will show scrollbars and look bad. I would like to hide the scrollbars no matter what.
Here is an Example
Is there any to hide scrollbar in this situation? I tried inspecting with chrome, but when I try adding a Overflow: hidden to IFRAME element, it does NOT hide.
You can do it like this:
<iframe src="https://css-tricks.com" width="100" height="100" style="overflow-y: hidden;" seamless="seamless" scrolling="no"></iframe>
add style="overflow-y: hidden;" seamless="seamless" scrolling="no" to your <iframe>
See fiddle example: https://jsfiddle.net/DIRTY_SMITH/7oe5kh9L/27/
I've looked at a few implementations of this and so far none have worked so I'm resorting to posting. The concept is: a placeholder image which once clicked changes into the video and autoplays.
Current HTML:
<div id="ytvideo" style="display:none;">
<iframe width="939" height="528" id="ytvideo" frameborder="0" allowfullscreen></iframe>
</div>
<img class="aligncenter size-full" id="homevideo" alt="placeholder" src="/wp-content/uploads/2013/10/placeholder.jpg" width="940" height="548" />
Current JS:
jQuery(document).on('click','#homevideo',function(e){
jQuery('#ytvideo').show();
jQuery('#homevideo').hide();
jQuery('#ytvideo').attr("src","www.youtube.com/embed/[myvidid]?autoplay=1");
jQuery("#ytvideo").attr('src', jQuery("#ytvideo", parent).attr('src') + '?autoplay=1');
});
I've looked at trying to reload the iframe but that doesn't seem to work.
Any ideas?
MARKED: FIXED
You forgot the protocol - www.youtube.com/… would link to folder on the server.
With protocol it works fine – I’d suggest creating the whole iframe dynamically though, because with an empty src attribute at the beginning it would load the same page it is embedded in.
<div id="ytvideo" style="display:none;"></div>
<!-- replaced your image with a span here for fiddle -->
<span id="homevideo" data-vidid="mbOEknbi4gQ">click me</span>
$(document).on('click','#homevideo',function(e){
$('#homevideo').hide();
$('#ytvideo').html('<iframe width="939" height="528" id="ytvideo" frameborder="0" allowfullscreen src="http://www.youtube.com/embed/'+$(this).attr("data-vidid")+'?autoplay=1"></iframe>').show();
});
http://jsfiddle.net/HuVqm/
As discussed in one of the comments, you can get both the img and the video from the api.
This would be good if you didn't want to maintain the image, just wanted it to pull through from YouTube. (However I am not sure that YT provide an image as large as 939 so in your case you might still want to use your own image). I have put in a random channel name 'RIDEChannel' feel free to change that with your channel name.
<div id="vid"></div>
$.getJSON("http://gdata.youtube.com/feeds/api/users/RIDEChannel/uploads?max-results=1&v=2.1&alt=jsonc&callback=?", function (myvid) {
var vid = $("#vid");
$.each(myvid.data.items, function (i, item) {
vid.append("<img width='300' height='250' src='" + item.thumbnail.hqDefault + "'>");
$(document).on("click", "#vid img", function (event) {
vid.append("<iframe width='300' height='250' src='http://www.youtube.com/embed/" + item.id + "?autoplay=1' frameborder='0'></iframe>");
$(this).hide();
});
});
});
So the problem laid with the youtube url missing the http:// prefix and also for the fact that the iframe name was the same as the div it was enclosed in. (How silly of me) Thus it was attaching the SRC to the div, not the iframe.
Working DEMO
Try this,
First you cannot have same id for more than one elements <div id="ytvideo" and <iframe id="ytvideo"
[myvidid] in http://www.youtube.com/embed/[myvidid]?autoplay=1 should be replaced with the id of the video
html
<div id="ytvideo1" style="display:none;">
<iframe width="939" height="528" id="ytvideo" frameborder="0" allowfullscreen></iframe>
</div>
<img class="aligncenter size-full" id="homevideo" alt="placeholder" src="http://thefabweb.com/wp-content/uploads/2012/12/6191814472_fa47c79b67_b-900x600.jpg" width="940" height="548" data-vid='DBNYwxDZ_pA'/>
code
jQuery(document).on('click','#homevideo',function(e){
jQuery('#ytvideo1').show();
jQuery('#homevideo').hide();
jQuery('#ytvideo').attr("src","http://www.youtube.com/embed/"+$(this).data('vid')+"?autoplay=1");
});
If you have more than 1 video, it could be useful to store the url to the video in the html and use a class instead of an id.
Also, if you put the preview image into the background, behind the video, it will stay there until the iframe has loaded, reducing that "flickering" effect when clicked.
I also restructured the markup a bit to reduce redundancy, here I specify the size of the video and the video id only once.
Also, you should use jQuery's .one('click') instead of .click(), since you want that event listener removed after it has fired the first time.
html:
<div class="ytvideo"
data-video="73sgatbknvo"
style="width:939px; height:528px; background-image:url(http://lorempixel.com/939/528/)">
<div class="seo">
Have a meaningful description of the video here
</div>
</div>
CSS:
.ytvideo {
background-position: center;
background-size: contain;
background-repeat: no-repeat;
cursor: pointer;
}
.ytvideo iframe {
border-style: none;
height: 100%;
width: 100%;
}
.ytvideo .seo {
display: none;
}
jQuery:
$('.ytvideo[data-video]').one('click', function() {
$(this).html('<iframe allowfullscreen src="//www.youtube.com/embed/'+$(this).data("video")+'?autoplay=1"></iframe>');
});
If you want to support browsers with no script support, you'd have to add a "noscript" element in the .ytvideo div that already contains the iframe.
fiddle:
http://jsfiddle.net/6ARc7/
I want to implement custom scrolling of iframe content for iPad. My solution is the following. I have iframe:
<div id="scroller" style="height: 300px; width: 100%; overflow: auto;">
<iframe height="100%" id="iframe" width="100%" name="iframe" src="1.pdf" />
</div>
And in javascript code I use:
top.frames['iframe'].scrollTo(x,y);
It works perfectly for pdf documents, but not for Excel and Power Point documents.
Does anyone have any suggestions?
It's not possible to show a worddocument or excel directly/correctly inside an Iframe.
You could use Google documents viewer/drive to present the documents with.
Check http://docs.google.com/viewer and https://drive.google.com/
But if it's possible, I would stick with PDF's
I have a simple webpage that used a include html file as the left navigation. Here is the code for each button:
<tr><td id="tdIndex" onmouseout="javascript:DoMouseOut(this)" onmouseover="javascript:DoMouseOver(this)"
class="menuDefault" onclick="javascript:NavPage('All_Rooms_Today.html');">All Rooms Overview</td></tr>
Here is the iFrame code on the parent page:
<iframe src="All_Rooms_Today.html" style="width: 100%; height: 500px" scrolling="yes" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0">
</iframe>
I need to write the javascript function navpage to populate the iframe.
Any help will be appreciated.
No need for JavaScript.
All Rooms Overview
<iframe name="name_of_frame" …>
You can almost certainly replace all the mouseover/out stuff with:
#some_container a {
display: block;
}
#some_container a:hover {
background: foo;
color: bar;
}
If you can't, then you should certainly remove the string javascript: as there is no use in having a label at that point (if you think it means "This is JavaScript", then you're wrong, for intrinsic event attributes you do that with a meta element).
For that matter, frames are a pain for bookmarking and for search engines (among other things). You're already using includes, you should probably keep using them and have proper pages including the navigation instead of framed pages.