在button的onclientclick事件中跳转网页,请高手指教
来源:百度知道 编辑:UC知道 时间:2024/05/21 09:17:53
我想问的是javascript:document.location.href="http://www.baidu.com";
为什么不能跳转?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default13.aspx.cs" Inherits="Default13" %>
<!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">
<title>无标题页</title>
<script type="text/javascript">
function myFuct()
{
//window.open("
为什么不能跳转?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default13.aspx.cs" Inherits="Default13" %>
<!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">
<title>无标题页</title>
<script type="text/javascript">
function myFuct()
{
//window.open("
你直接在button的单击事件里写:
Response.Redirect("页面.aspx");
你非要用脚本的话就:
Response.Write("<script>location.href='页面.aspx';</script>");
---------------------
你这里为什么不跳转.是因为你的imageButton是服务器端控件.要想使用脚本的的onclick的话.必须得给它注册事件.
this.imageButton1.Attributes.Add ("onclick","myFuct");
function myFuct()
{
//window.open("http://www.baidu.com");
window.location.href="http://www.baidu.com";
}
OnClientClick="myFuct();return false;"