简体   繁体   中英

Move a cursor position in iframe via javascript

i want some code to move the cursor position in an IFrame via Javascript or jquery. Really it will help me a lot.

Not possible. To answer why that's impossible, imagine:

  1. I include an iframe to some very important business (let's suppose for a moment this business does not have frame-busting code)
  2. When the user reaches my page, it begins manually controlling the cursor's position to highlight the "Delete Account" button, and simulates a click.
  3. User's account is deleted on a completely different site, through none of their input.

Javascript allows you many UI-coding capabilities, but ultimately the user is in control. Even events like the "onpageunload" are very much restricted in what they can do, and browsers will often include 'escape' options even there. Furthermore, even in the instance that you CAN find a way around these chains, it will frustrate and quite possibly even panic many of your users. I try to warn people that any instance in which you're "re-coding the browser" may lead to all sorts of unpredictable issues, and may even prevent handicapped accessibility to your site.

It might help us to know if there's some specific reason you'd like to do this - possibly the solution is not what you think it is. For instance, if you are trying to make an FPS using WebGL, I seem to remember Chrome including some function to allow for mouse control inside of a window (possibly taking a browser confirmation dialog)

You should check out

http://jqueryui.com/draggable/

You "could" put make the content in the iframe draggable, if you host the src for your frame. If you don't host the src for your Iframe, you "could" put have an inner iframe that is draggable, and an outer iframe that displays the inner frame. It is a very messy solution, I hope there is something better for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM