Disabling double click inside the IFRAME with remote source - javascript

Folks,
We have one strange requirement where we want to disable double click inside the IFRAME.
The complication here is HTML response is coming from remote URL and we donot have any control over it. Is it possible to disable double click inside this IFRAME.
e.g.
Iframe src="http://removeserver/view.jsp" height="300px" width="300px">
Note : We already investigated and it seems because of cross side scripting we cannot do this.Basically we cannot access HTML elements of page remoteserver/view.jsp as it is coming from remote web site.
Any help will be highly appreciated.

Empty div above iframe will disable any mouse actions on iframe content
http://jsfiddle.net/uxUF8/63/
<iframe with="300" height="300" src="https://www.youtube.com/embed/OsOYg5gpS0s" ></iframe>
<div style="position:absolute;margin-top:-300px;width:300px;height:300px;border:1px solid red;" ></div>
another version allows you to scroll inside http://jsfiddle.net/uxUF8/62/

Related

How i can stop dialoges in html page

I am trying to make html page that contain ads that prompt messages and dialoges like image below that makes redirects and loss original page and loss users
Example of dialoge
I want to stop any prompts or any dialoges on this page
My code is very simple html page with iframe
<iframe src="https://go.pub2srv.com/afu.php?id=1326365" height="500" width="900"></iframe>
Thanks
You could prevent the iframe from running Javascript by adding a sandbox attribute to the <iframe> element. Here's how it may look:
<iframe src="https://go.pub2srv.com/afu.php?id=1326365" height="500" width="900" sandbox=""></iframe>
You could refer to this page to understand how that works: https://www.w3schools.com/tags/att_iframe_sandbox.asp
Of course, this is the perfect solution because the iframe might require some privileges, in such case you could add specific privileges that the particular ad requires.

Disable download button from iframe tag

Im using the iframe tag to display videos in my site, but it keeps showing a download button (see the picture bellow) that I need to disable.
<iframe src="http://techslides.com/demos/sample-videos/small.mp"></iframe>
Is it possible to disable and to control this?
It should not be able to if the pages are from different domains.
It might work when the two pages are from the same domain. In this case you can try:
window.frames[0].document.getElementById('buttonId') ...//you can use javascript or jquery to remove this elment

auto click a specific location on an iframe using javascript/html

I'm fairly new to html so basically I have an Iframe and I want it to auto click a specific location when a user enters a website. I want it physically click the google search button Is it possible to give a location for a click? If so it would be helpful to display some code. This is what i got so far.
<html>
<iframe src="http://www.google.com" width="700" height="500" frameborder="1">
<p>Your browser does not support iframes.</p>
</iframe>
</html>
Assuming you can load www.google.com into an iframe, you might try adding a query string onto the end of the URL.
Something like https://www.google.com/#q=my+search+criteria
The user doesn't click anything, but search results are loaded (assuming Google will let you load its website in an iframe).

Inject Code into an iFrame to Hide a Specific Element

I am attempting to hide an element loaded in an iFrame using CSS/jQuery/Javascript. The iFrame content is located on a different domain. I am trying to hide a button on the page loaded inside the iFrame. The buttons HTML is:
<a href="/Communication" id="lbtnMessage" class="bsrpBlueButtonLink">
<div class="NavButtonMess">
<span>Messages</span>
</div>
</a>
I have read mixed answers around the Internet on whether or not this is possible. I just need to be able to hide this block of code in the iFrame source. I this at all possible?
One possible solution is to use postMessage, obviously you need to control both domains.
This jquery plugin handles it pretty well : http://benalman.com/projects/jquery-postmessage-plugin/
If you don't control both domains then, due to security this is impossible. All you can do, is resizing / hiding the iframe.

How to force a page to stay inside an iframe?

I want to allow any page to be loaded inside an iframe. It's for teaching purposes so I want to know if it's possible to force let's say:
<iframe src="http://www.wolframalpha.com/input/?i=5*sin%28x%29" width="400" height="100">
to stay inside the iframe. By default it has some kind of javascript that opens in full page.
UPDATE: What if i use frames? (please don't throw bricks at me) Could they know if the page is inside a frame?
If the page itself wants to break out of being framed with it's own javascript (which apparently this page is doing), it can do so and I know of no way to prevent it other than turning javascript off in your own browser which obviously isn't an option for general viewing.
On some browsers, you can set an attribute on the iframe element that sets a security policy that prevents the iframe from executing JavaScript. I don't remember the attribute name and not sure which browsers support it (I'm sure ie does, not quite sure about the others). If you have problem finding more details, I'll look it up when I get home (on a mobile right now)
edit: found it - security="restricted". Seems to be IE-only.
If you have links outside of this iFrame and want them to load into that iFrame on the same page, you'll have to give it a name, then target the named iFrame within your link's href.
<iframe src="http://google.com" name="myframe" hieght="100" width="100"></iframe>
<br />
Derp.
However, if you're loading a page into your iFrame that's loading links with target="blank", then those will go to a new window; unless you don't have access to those pages, you won't be able to change the links (short of writing JS to dive into your iFrame, etc).

Categories