我正在尝试使用函数 pageLoad() (asp.net 相关的 JS 事件)
我的主页中有一个,另一个页面中有一个。 由于某种原因,他们不想成为 friend ……只有一个被叫到。
当我取消一个时,另一个会被调用,所以我没有看到那里有问题......
有什么想法吗?
母版页:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="....." Inherits="......." %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script>
function pageLoad() {
alert('masterpage load');
CallStyledArrowSelect();
}
</script>
//more irrelevant code
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
在内容页面中:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script>
function pageLoad(){
alert('hi i'm not working');
}
//more code...
最佳答案
好的,
感谢 andrey.shedko对于链接,
显然不可能有 2 个 pageLoad 函数 - 一个在母版页中,一个在内容页中。 解决方案建议在内容页面上创建另一个函数,如果存在则调用它:
function pageLoad() {
// Master pageLoad() code.
// If function contentPageLoad exists, execute it.
if(typeof contentPageLoad == 'function')
contentPageLoad();
}
关于javascript - 页面和母版页中的 pageLoad 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26861654/