<html>
<head>
<title>ripped by diekiss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="calendar.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form>
<input onfocus="calendar(this);" type="text">
<input onfocus="month_x_2(this);" type="text">
</form>
</body>
</html>
这个是在页面中调用JS函数的代码,我现在用了以个模板页,我想在模板页中调用JS函数,该怎么调用那,我有点菜,查了资料仍然后点不怎么懂,(JS不怎么会用)有知道的发帖告诉下谢谢了
<head>
<title>ripped by diekiss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="calendar.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form>
<input onfocus="calendar(this);" type="text">
<input onfocus="month_x_2(this);" type="text">
</form>
</body>
</html>
这个是在页面中调用JS函数的代码,我现在用了以个模板页,我想在模板页中调用JS函数,该怎么调用那,我有点菜,查了资料仍然后点不怎么懂,(JS不怎么会用)有知道的发帖告诉下谢谢了
放在
<asp:Content ID="Content1" ContentPlaceHolderID="xxxx" Runat="Server">
下面~~~
我在MasterPage.master上添加内容页,我想在内容页上调用JS函数,我查了下,有人说把JS写在模板页中,然后在内容页中调用,我js很菜,所以发个帖子在这里问下该怎么调用
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
这个
<script src="calendar.js"> </script>
放在masterpage里面,所有的子頁都能調用這個js如果只想一個頁面調用,參照2樓
跟普通页一样,因为母版是在服务器端生成好了html返回,
js只在客户端有效。
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
<script type="text/javascript" language="javascript" src="calendar.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" />
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
我有一个css样式表一个单独的文件,一个js的单独文件
我在母版页的内容页里边的代码是这样的,
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript" language="javascript" src="calendar.js"></script>
<asp:TextBox ID="TextBox1" runat="server" Style="position: static" onfocus="month_x_2(this);"></asp:TextBox>
<script>
alert("成功")
</script>
</asp:Content>我的js文件里边有一个month_x_2()的函数,我想要的效果是,当我在textbox1上点击的时候执行month_x_2()这个函数,
但是现在出现了问题,缺少对象,可能就是没有执行者个函数,有知道问题出在哪里的朋友发个帖子谢谢了,JS和css的文件都是没有问题的,我在普通的html页面中调用是没有错误的,普通页面的代码如下<html>
<head>
<title>ripped by diekiss</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="calendar.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form>
<input onfocus="month_x_2(this);" type="text">
</form>
</body>
</html>
结贴
母版页调用js的用法和普通页面的调用方法一样,可以吧js放在母版页内在内容页直接掉用js函数,也可以吧js放在内容页内在内容页内直接调用
现在,在子页中调用js文件时,js文件里面生成了一个内部html页面。里面的对象无法识别。 该怎么解决呢