javascript之可拖动的iframe效果代码_javascript技巧
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript之可拖动的iframe效果代码_javascript技巧,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含11763字,纯文字阅读大概需要17分钟。
内容图文
// HISTORY// ------------------------------------------------------------------
// Jan 23, 2004: Fixed problems which caused the script not to work in
// some framed situations. Improved browser support.
// Added easier "addHandle" implentation.
// May 25, 2003: Added better event position detection, added caching
// of IFRAME object references to avoid lookups. Added
// 'move' cursor to handles.
// May 24, 2003: Updated to fix bug with Netscape 7.x
// May 23, 2003: Created
/*
DESCRIPTION: The purpose of this library is to allow IFRAME objects to be
dragged around the screen in the same way that popup windows or draggable
DIV tags are often used. Since IFRAME objects always cover form objects,
this makes an ideal solution for a simulated "popup window" on a page with
form objects.
COMPATABILITY: Tested successfully with IE 6.x, Netscape 6.2, 7.x, and
Mozilla 1.3. Since this script uses IFRAME objects and DHTML heavily,
cross-browser compatability is a goal but there may be some quirks in
various browser versions.
USAGE:
1) Include the source file in your main document which contains the IFRAME
tags. Make sure each iframe has a unique "ID" attribute. For best browser
compatability, also include a "NAME" attribute in the IFRAME tag that
has the same value as the "ID" attribute.
2) In the document content of each IFRAME which will be draggable, , do two
things:
a) Include the dragiframe.js file in the source
b) add this code to the tag:
onLoad="addHandle(document.getElementById('toolbar'), window);"
Where 'toolbar' is the ID of an element on the page which should be the 'handle'
by which the IFRAME should be dragged (like a toolbar at the top).
If you want the IFRAME to be draggable by clicking anywhere in the IFRAME
document, use:
onLoad="addHandle(document.getElementsByTagName('body').item(0), window);"
NOTE: The code will automatically look up the window.parent tree to find a
parent document with draggable iframes enabled. It will attach itself to the
first document it finds, allowing it to work within a framed environment.
In your parent document (containing the IFRAMEs), you may set a couple of options:
// Set to true to always bring the selected IFRAME to the "top" of the zIndex.
// Defaults to false
bringSelectedIframeToTop(true|false);
// Set to true to allow IFRAME objects to be dragged off the screen. This may
// make the handle be no longer reachable by the mouse, causing the IFRAME to
// be stranded.
// Defaults to false
allowDragOffScreen(true|false);
// You may manually set this variable to define the highest zIndex used in
// your main document. This is used to determine what zIndex to give an IFRAME
// if it is selected and "bringSelectedIframeToTop" is set to true.
// Defaults to 99.
DIF_highestZIndex=4;
NOTES:
1) If you have defined onmousedown or onmouseup event handlers for your "handle"
object in the IFRAME, they will be over-written.
2) If you have defined an onmousemove handler in either the main document or
the IFRAME document, they will be over-written.
3) All
内容总结
以上是互联网集市为您收集整理的javascript之可拖动的iframe效果代码_javascript技巧全部内容,希望文章能够帮你解决javascript之可拖动的iframe效果代码_javascript技巧所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。