[转]Using the Popup Object

Using the Popup Object

Internet Development Index

The popup object enables you to create window objects that take full advantage of Dynamic HTML (DHTML). Click the Show Me button to see some of the exciting things that can be done using a popup.

Show Me

This article first outlines the important features of the popup object. Several of these features and the basic syntax to use with the popup object will then be demonstrated. Alternatives to the popup will be explored in the last section.

Features

Below is a list of important features of the popup object. Many of these features make the popup object useful for creating custom menus and displaying quick reference information.

  • Unlike most window types, popup object does not have border chrome around it. The following graphic is a window with border chrome.

    Window With Border Chrome

  • A popup object always closes when the user clicks away from it or when another popup object is opened.
  • The popup object never has focus when it is displayed so processes continue to run in the parent window.
  • DHTML that populates the popup object can be stored inside the parent document or in another document.
  • The popup object does not support text boxes of any kind.
  • No elements inside of the popup object can be selected.
  • No navigation can occur inside the popup object itself (clicking a link will launch navigation in the parent window or a new instance of the browser).
  • Once displayed, the popup object cannot be moved by the user.
  • The popup object cannot be resized by the user.

Syntax and Focus

The popup object is created by the createPopup method, displayed by the show method, and closed by the hide method. The following example shows how to use the basic syntax. It also shows how a user can type inside a text box while a popup is displayed because the popup object never has focus.

Note  For simplicity, the code for formatting has been omitted from some of the examples in this article. To view all of the code, view the source code inside of the Show Me examples.

Show Example

<HTML>
<HEAD>
<TITLE>Basic Popup Example</TITLE>
<SCRIPT LANGUAGE="JScript">


var oPopup = window.createPopup();
function openPopup()
{
    
    
    var oPopBody = oPopup.document.body;
    
    oPopBody.innerHTML = "<DIV>This is a popup.</DIV>"
    
    
    
    
    oPopup.show(15, 150, 50, 50, document.body);
}
</SCRIPT>
</HEAD>
<BODY>

<TEXTAREA οnclick="openPopup();" ROWS="6" COLS="30" WRAP STYLE="width:100%">
Click in here to open a popup object.</TEXTAREA>

</BODY>
</HTML>
Show Me
Note  Because the popup object never takes focus, focus related events such as onfocus and onblur are not applicable to the popup object.

Popup Glossary Definitions

You can use the popup object when you want to display quick reference information in an unobtrusive manner. The popup object closes when the user clicks away from it so the user can click on one popup object after another and then on the parent window without having to close numerous windows. This feature enables the popup object to act like a typical drop-down menu or a popup glossary definition.

The following example shows how to use the popup object to create glossary definitions.

Hide Example

<HTML>
<HEAD>
<TITLE>Popup Glossary Definition Sample</TITLE>
<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function fnDef()
{
    if (event.srcElement.id == "brasshat")
        oPopup.document.body.innerHTML = oBrassHat.innerHTML;
    else if (event.srcElement.id == "entrechat")
        oPopup.document.body.innerHTML = oEntrechat.innerHTML;     
    var popupBody = oPopup.document.body;
    
    
    
    
    
    oPopup.show(0, 0, 300, 0);
    var realHeight = popupBody.scrollHeight;
    
    oPopup.hide();
    
    oPopup.show(0, 15, 300, realHeight, event.srcElement);
}
</SCRIPT>
</HEAD>
<BODY>

The <SPAN ID="brasshat" οnclick="fnDef();">brass hat</SPAN> 
was impressed by the grace of the dancer's 
<SPAN ID="entrechat" οnclick="fnDef();">entrechat</SPAN>.

<!-- Nested DIVS inside this hidden DIV store the code that populates the
popup object. -->
<DIV STYLE="display:none;">
    <DIV ID="oBrassHat">
        <DIV>
            <B>brass hat:</B><BR>
            A high-ranking official.
        </DIV>
    </DIV>
    <DIV ID="oEntrechat">
        <DIV>
            <B>entrechat:</B><BR>
            A jump in ballet during which the dancer crosses the legs a 
            number of times, alternatively back and forth. 
        </DIV>
    </DIV>
</DIV>
</BODY>
</HTML>
Show Me

Storing Popup Code in a Separate Document

In the preceding example, the HTML that populates the popup object is stored in a hidden div inside the document itself. The popup object can also access code from another document. You can treat this separate document as a normal HTML document. This is advantageous when you use imported style sheets, style blocks, and script tags for reasons including that the popup object is separate from the parent window and elements like style blocks in the parent are not available to the popup object.

The following example shows how to populate a popup object by accessing DHTML from another document using the default download behavior. It also demonstrates how popup objects are useful for menu applications. With a popup object, it is easy to click one menu-activating element after another. The previous menu automatically closes when the next one opens because only one popup object can be open at a time.

Hide Example

<HTML>
<HEAD>
<TITLE>Popup Parent</TITLE>
</HEAD>
<BODY BGCOLOR=lightyellow>
<!-- The DOWNLOAD element is user-defined and used only to associate the 
download default behavior with an identifier that is then associated with the 
startDownload method later in the script. -->
<DOWNLOAD ID=dwn STYLE="behavior:url(#default#download)" />

<SCRIPT>
    
    function onDone(src){
	    oPopup.document.write(src); 
    }
    function showPopup(){	
	    oPopup.show(0, 0, 220, 30, editbutton);
    }
    
    var oPopup = window.createPopup();
    
    
    
    
    dwn.startDownload("PopupHTML.htm",onDone);	
</SCRIPT>

My Favorite Weather is:
<INPUT ID="inputid" TYPE="text" VALUE="Rain">
<INPUT ID="editbutton" TYPE="Button" οnclick="showPopup();" VALUE="Edit">
</BODY>
</HTML>

The following document contains the DHTML that populates the popup window.

Hide Example

<HTML>
<HEAD>
<TITLE>Popup Window</TITLE>
<SCRIPT LANGUAGE="JScript" >



function clickPopup(){
	if (event.srcElement.tagName == "IMG"){
		parent.inputid.innerText = event.srcElement.id;
		parent.oPopup.hide();
    }
}
</SCRIPT>
</HEAD>
<BODY οnclick="clickPopup();" style="border:solid 1; 
background-color:darkblue; overflow:hidden; margin-top:2px; margin-right:2px;
margin-left: 2px; margin-bottom:2px">
<IMG src="Sunny.gif" id="Sunny">
<IMG src="Partly Cloudy.gif" id="Partly Cloudy">
<IMG src="Mostly Cloudy.gif" id="Mostly Cloudy">
<IMG src="Cloudy.gif" id="Cloudy">
<IMG src="Rain.gif" id="Rain">
<IMG src="Snow.gif" id="Snow">
</BODY>
</HTML>
Show Me

Popup Navigation Menus

Another application of the popup object is custom browser navigation menus that render a URL in the parent window. The following example shows how to make custom navigation menus (activated by right-clicking the document) using the popup object.

Hide Example

<HTML>
<HEAD>
<TITLE>Popup Custom Navigation Menu Sample</TITLE>
<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function contextMenu()
{
    
    
    
    var lefter = event.offsetX+10;
    var topper = event.offsetY+10;
    oPopup.document.body.innerHTML = oContextHTML.innerHTML; 
    oPopup.show(lefter, topper, 200, 65, document.body);
}
</SCRIPT>
</HEAD>
<BODY οncοntextmenu="contextMenu(); return false;">
<h1>Creating Custom Context Menus with the Popup Object</h1>
Right-click anywhere on the document to see a customized popup navigation 
menu.
<DIV ID="oContextHTML" STYLE="display:none;">
    <DIV οnmοuseοver="this.style.background='gold';" 
         οnmοuseοut="this.style.background='#e4e4e4';">
    <SPAN οnclick="parent.location.href='http://msdn.microsoft.com'">
    MSDN Web Workshop</SPAN> 
    </DIV>
    <DIV οnmοuseοver="this.style.background='gold'" 
         οnmοuseοut="this.style.background='#e4e4e4'" 
    <SPAN οnclick="parent.location.href='http://search.microsoft.com'">
    Search</SPAN> 
    </DIV>
</DIV>
</BODY>
</HTML>
Show Me

Alternatives to the Popup Object

ToolTips and dialog boxes are similar to popup objects and can be used for similar applications. However, there are a number of key differences which are discussed below.

Popup Object vs. Dialog Boxes

The most important differences between popup objects and dialog boxes are the following:
  • Dialog boxes must be addressed directly in some way in order to close them. The popup object, on the other hand, closes by simply clicking away from it. This is why the popup object is often used to create menus and glossary definitions as illustrated earlier in this article.
  • Dialog boxes must have border chrome around them unless they are being used in a trusted application such as an HTML Application (HTA). The popup object does not have this requirement giving you more control of its appearance. This is especially useful when creating custom menus and message boxes.
  • Dialog boxes always take focus when they are first opened. If you want processes to continue to run in the parent window, the popup object can be used.
  • Dialog boxes support all types of form elements including text boxes. The popup object does not support text boxes and is not meant to be used to gather sensitive information from the user.

For more information about dialog boxes and the many uses for dialog boxes, see The Importance of Good Dialog.

Popup Object vs. ToolTips

You can create applications similar to the glossary definition example earlier in this article using ToolTips created by the TITLE attribute or the ToolTip behavior. However, a ToolTip does not support full DHTML and does not have the flexibility of popup objects. ToolTips also close when the pointer moves away from the element that contains the ToolTip or after a time period if the cursor does not keep moving over the element. On the other hand, ToolTips are often simpler to use and can require less code. Also noteworthy is that ToolTips will automatically close when a popup is opened.

Related Topics


trans_pixel.asp?source=msdn&TYPE=PV&p=workshop_author_om_popup&URI=%2flibrary%2ftoolbar%2f3.0%2fasp.aspx%3fmode%3dhead%26c%3d%2fnonlibraryshell.config%26h%3dmsdn%252Emicrosoft%252Ecom%26u%3d%252Fworkshop%252Fauthor%252Fom%252Fpopup%255Foverview%252Easp%26r%3dhttp%253A%252F%252Fmsdn%252Emicrosoft%252Ecom%252Flibrary%252Fshared%252Fdeeptree%252Fasp%252Frightframe%252Easp%253Fdtcfg%253D%252Flibrary%252Fdeeptreeconfig%252Exml%2526url%253D%252Fworkshop%252Fauthor%252Fom%252Fpopup%255Foverview%252Easp%253Fframe%253Dtrue%2526hidetoc%253Dfalse&GUID=1F4FC18C-F71E-47FB-8FC9-612F8EE59C61&r=http%3a%2f%2fmsdn.microsoft.com%2flibrary%2fshared%2fdeeptree%2fasp%2frightframe.asp%3fdtcfg%3d%2flibrary%2fdeeptreeconfig.xml%26url%3d%2fworkshop%2fauthor%2fom%2fpopup_overview.asp%3fframe%3dtrue%26hidetoc%3dfalse

转载于:https://www.cnblogs.com/Elong/archive/2005/07/25/199505.html

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
应用背景为变电站电力巡检,基于YOLO v4算法模型对常见电力巡检目标进行检测,并充分利用Ascend310提供的DVPP等硬件支持能力来完成流媒体的传输、处理等任务,并对系统性能做出一定的优化。.zip深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值