当前位置:首页 » 文件传输 » js访问网页
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

js访问网页

发布时间: 2022-02-23 19:00:20

㈠ 网页如何调用js代码

有2种方式:

  1. 内联:你直接在<head></head>里面加上<script type=text/javascript>(这里面就是可以写你的JS代码了)</script>

    1. PS:其实你的JS代码可以写在HTML的任何地方,但是可能会出错,所以一般都是写在头部,而不是写在其他位置。

  2. 外联:就是你自己创建一个JS文件,然后把你的代码写在JS文件里面,在HTML页面里面,你可以通过在头部中加上<script type="text/javascript" src="你的JS文件路径和文件名"></script>

㈡ js里面有什么方法可以打开一个网页

<script>
window.location.href="新页地址";//将本页替换成新页面
window.open("新页地址");//弹出一个新页面
</script>

㈢ 怎么用js调用另一个网页!

区分干么?你要调用哪个文件里的功能或函数就直接用代码调用就行了.如:
a.js中有一个功能ShowName()
b.js中有一个功能HelloMsg()
在文件中调用:
<script>ShowName();</script>
可能在另一个地方要调用第二个则用相同的方法:
<script>HelloMsg()</script>

是这样的,在HEAD里写的是对JS的外部连接(文件连接,不然用不了那个文件里的代码)
你再仔细看看BODY里的内容,肯定会有JS调用语句的,如果没有,可能在那两个JS里设置好了调用或就是直接实现功能的语句,而不是用函数形式提供的.JS调用的方式很多,有隐藏的有明显的.

㈣ 请问,大家谁有最简单的js调用网页的方法要最简单的!

一、第一种情况:

1.后台方法:

protected string CsharpVoid(string strCC)
{

return strCC;

}

2.javascript 调用
<script language="javascript">

var s = "<%=CsharpVoid("")%>";
document.write(s);

</script>

第二种情况:

1.后代码:
protected void CsharpVoid()
{
string strCC = "";
Response.Write(strCC);

}

2.调用方法:CsharpVoid()

<script language="javascript">
document.write("<%CsharpVoid();%>");
</script>

第三种方法:
你可在页面中放一个按钮,把它设置为不可见style="display:none",然后,用脚本让此按钮点击
document.all("button1").click();
在此按钮的C#后台中写事件代码,这就是最简单的脚本调用C#方法.

二、我要的结果是当我去点按钮时,在去带参数去触发后台方法.怎么样写高手指点

HTML code:
<html xmlns="">
<head runat="server">
<title></title>

<script type="text/javascript">
function Say(strValue) {
PageMethods.SayH(strValue, ShowMsg);
}
function ShowMsg(result) {
var sResult = result.toString();

document.getElementById("rMsg").innerHTML = sResult;
}

</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<input id="Button1" type="button" value="点击我" onclick="Say('你是猪');" />
</div>
<div id="rMsg">
</div>
</form>
</body>
</html>

C# code:
[System.Web.Services.WebMethod]
public static string SayH(string name)
{
return string.Format("welcome to site , !", name);
}

好人有好报 希望能采纳 嘿嘿!!!

㈤ 如何在js页面调用html页面呢急用啊

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="http://www.e0757.cn/lwf_js/jquery-1.4.min.js"></script>
<script language='javascript'>
$(document).ready(function() {

//处理代码
$.ajax({
async:true,
url: 'foot.html',
type: 'GET',
dataType: 'html',
timeout: 10000,
error: function(){
//alert('Error loading TEXT document');
},
success: function(html){
// do something with xml
$("#foot").html(html)
}
});

});
</script>

</head>

<body>
<div id="head" class="ajaxLoadDiv" style="width:960px;height:500px"></div>
<div id="foot" class="ajaxLoadDiv" style="width:960px;height:70px"></div>
</body>
</html>

㈥ 如何用JS读取html文件中的内容到另外的一个HTML页面上

1、首先新建文件。


注意事项:

因为Netscape与Sun合作,Netscape管理层希望它外观看起来像Java,因此取名为JavaScript。但实际上它的语法风格与Self及Scheme较为接近。

㈦ js怎么调用另一个页面的内容

1、必须两个页面在同一个域
2、将两个页面的js拿出来,保存为a.js
3、在两个页面里都引用这个a.js,那么里面的函数在两个页面里都能使用了

㈧ 使用js或jquery调用网页并显示出来

<style>
div{
witdh:100%;
height:100%;
}
</style>
<divid="target"></div>
<scriptsrc="jquery.js"></script>
<script>
$("#target").load("
);
</script>

不好意思,我想的太简单了,这种ajax请求是不能跨域的,所以不能用这种方法直接加载html,使用frame是直接,简单的方式,否则只能用jsonp来跨域请求,但是这要求别人的服务器响应您特殊的参数,所以请无视我的答案

㈨ JS 调用当前页面url

严谨一点最好在form提交的时候再对当前页地址取值:

$(function(){
varurl="{fy:dir}user/Checklogin.asp?Action=LoginCheck&olrl="+window.location.href;
$("#FormID").attr("action",url);
});

form直接写在代码里,不用js输出吧:

<formaction=""id="FormID"method="post"class="simformulogin">

㈩ 怎么用js打开本地网页

可以打开,不过需要完整的url地址。
类似window.open('http://127.0.0.1:8888/test_demo/test3.html');
但是需要设置浏览器,一般浏览器会阻止弹出框的。