How to Apply onmouseover to an Entire Frame? - javascript

I have a frame that I want to run the equivalent of an onmouseover event whenever (surprise, surprise) someone mouses over the frame. I know I cannot use onmouseover with the frame or frameset tags. What could I do that would have the same effect as <frame onmouseover=""...?

<frame> s are deprecated in modern versions of html.
You can just do something like:
<div onmouseover="javascript:alert('Hello!');" >
<iframe ...></iframe>
</div>

Related

Frames are not working properly in IE and FF

Im currently working on some legacy project.
I've got an HTML-file which contains a <frameset> with a bunch of <frame> elements.
My task was to inject a js-script into this html to add a sidebar and header with some styles. I did a bunch of manipulations with frames, resizing it to make my sidebar and header fit. So far i've been testing it in Google Chrome and it worked just fine. Once i finished next step was to test it in other browsers and it just did not work anywhere. (My interest so far is in IE and FF, so i tested there).
To specify what's not working: My new sidebar and header is fine, fully rendered, but all the frames are not visible. They exists in the DOM but any size of any frame is 0 width.
Initial html works just fine in every browser.
I guess the problem is with resizing the frames, but im struggling to find any solution or even cases like mine. Maybe im missing something big about the frames.
Initial document frameset is like this:
<FRAMESET rows="32px,*">
// here is some frames
</FRAMESET>
With a js inject i rebuild this html to this:
<body>
<div id='main'>
<div id='main_menu'> //menu
</div>
<div id='main_frameset'>
<frameset cols="81px,*" border="0" framespacing="0">
<frame></frame>
<FRAMESET rows="32px,*"> <-- Initial frameset
</FRAMESET>
</frameset>
</div>
</div>
</body>
An HTML document with a <frameset> has it instead of a <body>. It isn't an element you can drop in anyway (that's an <iframe>).
If you want to add a new sidebar and header, add them as frames.
I found the solution to my problem.
Thanks to #Teemu.
If somebody meet something like i did the best solution is to wrap your deprecated part in <iframe> element. In my case it transformed my DOM to this:
<div id='main_frameset'>
<iframe>
<#document>
<head></head>
<frameset cols="81px,*" border="0" framespacing="0"> <-- Previous wrap
<frame></frame>
<FRAMESET rows="32px,*"> <-- Initial frameset
</FRAMESET>
</frameset>
</#document>
</iframe>
</div>
By default this iframe element will be 300x150 with border and scrolls (both horizontal and vertical) on. I added some properties:
scrolling="no" - disable scrollings.
frameborder="0" - disable border.
width="100%" (Not style.width, just width).
height="100%"(Not style.height, just height).
Width did fine, it stretched out iframe to full remaining space, but height, for some reason didnt want to work (still was 150px). After some time i understood that this properties position themselves to the parent element. So i added height: calc(100vh - #myHeaderHeight) to the parent <div id='main_frameset'> and everything settled well.
Another issue was to write my previous html into the iframe. You have to access inner document with iframe.contentWindow.document property only by using onload event. This is the way to prevent case when its not fully loaded at the time you try to modify it. Accidentally, iframes' body has default margin, so i recommend reset it 0 too. In my case i fully replaced <body> with <frameset> to prevent further issues like initial.
I hope nobody will ever need to read this answer and wont use anything that is so outdated.

Prevent iframe js from auto scrolling the parent page

We have a page that has a video on it, embedded with an iframe.
The iframe js code for the player has the following code in it:
m.default.focus(function (e) {
var t = e.playButton;
(0, y.focusElement) (t)
})
This basically makes the play button visible on the screen if it isn't already. Which is fine for stand alone videos, but not on a page where we have the video embedded.
What it does framed in on our page is cause the entire page to scroll to that content.
We'd like to prevent that if possible.
Here is the iframe code:
<div class="embed-responsive mb-5 embed-responsive-16by9" id="myFrame" style="height: auto;">
<iframe allowfullscreen="" class="embed-responsive-item" sandbox="allow-scripts allow-downloads-without-user-activation allow-same-origin" src="https://sourcefile.onthesamedomain.com" title="Video"></iframe>
</div>
We've tried the scroll to 0,0 on the parent but that didn't work.
Apologies, but I forgot to add that this is only an issue in Firefox. The other browsers work with the attributes on the iframe.
Any help would be appreciated.
The 3rd party owner of the js within the iframe ended up providing a fix. There was no way we could do this without the screen scrolling back and forth.

Javascript disable double click on canvas

I have an issue about embedded canvas is that I don't want
to use double click feature on it.
While API given by Sketchfab doesn't offer such functionality, is there a way to block event getting there in the first place ?
UPDATE:
I am embedding model from Sketchfab.
Here's the embed:
<div class="sketchfab-embed-wrapper"><iframe width="640" height="480" src="https://sketchfab.com/models/9eb60eebc20e45c4b586e1a6fe6c5983/embed" frameborder="0" allowvr allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>
...
Since you stated that you are using Sketchfab (which is embedded with an iframe) this is not possible due to XSS protection. No major browser will allow you to access embedded cross site content.
Take a look at this link for more information about cross-frame scripting and security.
can you check this? Remove Event
$('canvas').off('dblclick');
https://jsfiddle.net/gtbypwLb/

How to remove any div in iframe

Hi Please tell me how can we remove any div in iframe for example my code is :
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<iframe src="http://stayupdate.net" width="100%" height="800">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
I want to remove "creditline" div or its text
<div id="creditline">
<span class=".alignleft">
</span>Designed By
Real Web Maker
</div>
You can change only if you have access(file) to that page..Otherwise its not possible to change the content of other's page.And it should be.
Don't no about your requirement but..But you can do a trick.
Create a same size div,change the content according to you requirement.
and by js or jquery put it exactly over iframe div.
Is not recommended at all,and its not reliable too.
I suppose you want to add script to your page, which removes a div tag inside the iframe. This is only possible if the page shown by the iframe (http://stayupdate.net) has a provision to do that. If you can modify the inner page, then you could add an event listener, which accepts an external command to remove a tag. The outer page can then send that command using postMessage, as described here. If the outer and inner pages are in the same domain, you can use a simple function call as described here.

Javascript in Iframe within Div not working

I have a webpage that I would like to embed within another page. On the page that is to be embedded I have some window.onload javascript that will load a PDF document via the embed tag. If I use just the Iframe tag like this:
<iframe name="content" id="iframe" allowtransparency="true" src="Pages/menu.html" scrolling="no"></iframe>
The Javascript will run just fine. But I am trying to create a background and border for the iframe so I have wrapped the iframe in a div like so:
<div id="content" class="border">
<iframe name="content" id="iframe" allowtransparency="true" src="Pages/menu.html" scrolling="no"></iframe>
</div>
As soon as I do it this way the javascript will not run. Here is the screenshot of what I am trying to do. I do not believe that the styling that is present on the div ( curved borders, gradient, etc is possible on an iframe)
I am using PDFObject to generate the PDF on the page. The iframe is also loading the company's external website in the content section on demand and this is what they want so unfortunately i have to use iframes. This has to be done without using anything except javascript as well otherwise I would just use php.
I have to post the SCREENSHOT outside of this site on photobucket due to restritions sorry:
http://i721.photobucket.com/albums/ww217/the_t3rminat0r/Capture-2.png
It looks margin property in div style (or border class in your example) causes the problem.

Categories

Resources