帮助为什么jQuery可以在HTML中工作,但不能在aspx Web窗体中工作 [英] help why jquery works in html but dont work in aspx web form
问题描述
我正在尝试以aspx web形式使用jquery示例
有关示例代码的一点信息
此samole代码显示具有淡入和淡出效果的中心屏幕弹出窗口
现在我的问题是什么
我尝试了2天以aspx web形式实现jquery,但是每次尝试都失败了.
相同的jQuery在html中像黄油一样运行
我正在使用vs 2008
成功为intelsense安装修补程序
将jquery-1.6.2.js放在同一文件夹中
将用于智能感知的jquery-1.6.2vsdocs.js放在同一文件夹中
当我在浏览器中运行并在按钮弹出窗口上单击后,将相同的html代码放在aspx web表单中的表单标签中时,根本不显示自己,但是当我将
i am trying to use jquery sample in aspx web form
bit about sample code
this samole code shows a center screen popup window with fadein and fadeout effect
now whats my problem
i tried for 2 days on implementing jquery in aspx web form but failed on every try.
same jquery runs like butter in html
i am using vs 2008
installed hotfix for intelsense successfully
put jquery-1.6.2.js in same folder
put jquery-1.6.2vsdocs.js for intellsense in same folder
when i put same html code in aspx web form in the form tag after runing in browser and clicking on button popup doesnt show himself at all but when i put
超出了它可以完美运行的表单标记的范围,这是没有用的
我要去哪里了
out side the form tag it runs perfectly which is useless
where i am going wrong
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>yensdesign.com - How to create a stuning and smooth popup in jQuery</title>
<link rel="stylesheet" href="general.css" type="text/css" media="screen" />
<script src="jquery-1.2.6-vsdoc.js" type="text/javascript"></script>
<script src="popup.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<a href="http://www.yensdesign.com"><img src="logo.jpg" alt="Go to yensdesign.com"/></a>
<div id="button"><input type="submit" value="Press me please!" /></div>
<div id="popupContact">
<a id="popupContactClose">x</a>
<h1>Title of our cool popup, yay!</h1>
<p id="contactArea">
Here we have a simple but interesting sample of our new stuning and smooth popup. As you can see jQuery and CSS does it easy...
<br/><br/>
We can use it for popup-forms and more... just experiment!
<br/><br/>
Press ESCAPE, Click on X (right-top) or Click Out from the popup to close the popup!
<br/><br/>
<a href="http://www.yensdesign.com"><img src="logo.jpg" alt="Go to yensdesign.com"/></a>
</p>
</div>
<div id="backgroundPopup"></div>
<div>
</div>
</form>
</body>
</html>
/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
/***************************/
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
if(popupStatus==0){
$("#backgroundPopup").css({
"opacity": "0.7"
});
$("#backgroundPopup").fadeIn("slow");
$("#popupContact").fadeIn("slow");
popupStatus = 1;
}
}
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("slow");
popupStatus = 0;
}
}
//centering popup
function centerPopup(){
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popupContact").height();
var popupWidth = $("#popupContact").width();
//centering
$("#popupContact").css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
//only need force for IE6
$("#backgroundPopup").css({
"height": windowHeight
});
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
//LOADING POPUP
//Click the button event!
$("#button").click(function(){
//centering with css
centerPopup();
//load popup
loadPopup();
});
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
});
//Click out event!
$("#backgroundPopup").click(function(){
disablePopup();
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
});
推荐答案
(" ).css({ " :" 0.7" });
("#backgroundPopup").css({ "opacity": "0.7" });
(" ).fadeIn (" );
("#backgroundPopup").fadeIn("slow");
(" ).fadeIn(" 慢"); popupStatus = 1 ; } } // 使用jQuery Magic禁用弹出窗口! 功能 disablePopup(){ // 仅在启用弹出窗口时将其禁用 如果(popupStatus == 1 ){
("#popupContact").fadeIn("slow"); popupStatus = 1; } } //disabling popup with jQuery magic! function disablePopup(){ //disables popup only if it is enabled if(popupStatus==1){
这篇关于帮助为什么jQuery可以在HTML中工作,但不能在aspx Web窗体中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!