我想彈出一個模式,我知道這個代碼的作品,但由於某種原因,我的js要麼不加載或不到$ document.ready。我有一個警報,我在調試模式下運行,它甚至沒有開火。
,這裏是我的.aspx與腳本加載JS
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RCC_ChgPassTester.aspx.cs" Inherits="Regal.Web._Tester.RCC.RCC_ChgPassTester" %>
<%@ Register Src="RCC_ChangePassword.ascx" TagPrefix="Rcc" TagName="RCCChgPass" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/assets/css/home.css" media="all" rel="stylesheet" type="text/css"/>
<link href="/assets/css/modal.css" media="all" rel="stylesheet" type="text/css"/>
<link href="/assets/css/rcc-main.css" media="all" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="http://www.regmovies.com/assets/css/jquery-plugins.css"/>
<!-- <link rel="stylesheet" href="/assets/css/global.css" /> -->
<script type="text/javascript" src="/assets/js/jquery.js"></script>
<script type="text/javascript" src="/assets/js/jquery-plugins.js"></script>
<script type="text/javascript" src="/assets/js/jquery.openCarousel.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
window.jQuery || document.write('<script type="text/javascript" src="/assets/js/jquery.js">\x3C/script>') /*]]>*/
</script>
<script type="text/javascript" src="../_assets/js/RCCTester.js"></script>
</head>
<body id="body" style="background-image:url(http://www.regmovies.com/~/media/Images/Site%20Takeovers/wallpaper_cloudyNP.ashx);">
<form id="form1" runat="server">
<div>
<RCC:RCCChgPass runat="server" ID="ChgPass" />
</div>
</form>
</body>
</html>
,這裏是我的腳本:
(function (window) {
var
$ = window.jQuery,
modalLocation = '#modal-password-change',
modalPasswordChangeOpts = {
autoOpen: true,
modal: true,
resizable: false,
draggable: false,
width: '450',
height: '550',
dialogClass: 'modal',
close: function() { $(this).dialog('destroy'); }
};
function showModal() {
$(modalLocation).dialog($.extend(modalPasswordChangeOpts))
$(modalLocation).dialog('open');
}
$(document).ready(function() {
RCC.showModal();
alert("I am here");
return false;
});
window.RCC = window.RCC || {};
window.RCC.showModal = showModal;
});
控制檯拋出的任何錯誤?它不應該只是'showModal()'而不是RCC.showModal() – charlietfl
什麼是'window.jQuery || document.write(...'code for?我知道類似的代碼有時用於人們從CDN中包含jQuery,他們在那裏測試包含是否工作,如果不使用本地副本,但您使用的是相同的代碼作爲原始路徑包括...(你正在做它_after_包括依賴於jQuery已經在那裏的插件) – nnnnnn