1.0.6 js window对象(window,location,screen,history,popupAlert,timing,cookie)

<!DOCTYPE html>
<html encoding="gbk">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"></meta>
<script>
//js widnow对象
function windowMethod(){
//该例显示浏览器窗口的高度和宽度:(不包括工具栏/滚动条)
var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
alert('屏幕的宽:' + w + ' 屏幕的高:' + h );
var str= 'window.innerWidth=' + window.innerWidth + ' ; window.innerHeight='+ window.innerHeight + '<br />' +
'document.documentElement.clientWidth=' + document.documentElement.clientWidth + ' ; document.documentElement.clientHeight='+ document.documentElement.clientHeight + '<br />' +
'document.body.clientWidth=' + document.body.clientWidth + ' ; document.body.clientHeight='+ document.body.clientHeight + '<br />' ;

//document.getElementById('div1').innerHTML=str;
}


//js screen
function screenMethod(){
/*
screen.availHeight 属性返回访问者屏幕的高度,以像素计,减去界面特性,比如窗口任务栏。
screen.availWidth 属性返回访问者屏幕的宽度,以像素计,减去界面特性,比如窗口任务栏。
返回屏幕的可用宽度和高度(注意:可用宽度和可用高度不会随着窗口的变化而变化,即该值是固定的)
*/
alert( '屏幕的可用宽度:'+screen.availWidth + ' --屏幕的可用高度:' + screen.availHeight);

}

//JS Location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面。

function locationMethod(){
//返回 web 主机的域名
var hostName=location.hostname; //
//返回当前页面的路径和文件名
var pathName=location.pathname;
//返回 web 主机的端口
var port=location.port;
//返回所使用的 web 协议(http:// 或 https://)
var protocol=location.protocol;
//当前页面的 URL
var url=location.href;

/*
alert(hostName + '\n' +
pathName+ '\n' +
port+ '\n' +
protocol+ '\n' +
url+ '\n' );

*/
//通过assign()方法加载新的文档
//location.assign("http://www.w3school.com.cn");
location.assign("demo61.html");
}


//JS History 对象包含浏览器的历史。
function historyMethod(){
//后退按钮 history.back() 方法加载历史列表中的前一个 URL。
//window.history.back();

//前进按钮 history forward() 方法加载历史列表中的下一个 URL
window.history.forward();

}

//window.navigator 对象包含有关访问者浏览器的信息。
function navigatorMethod(){
var codeName=navigator.appCodeName;
var appName=navigator.appName;
var cookieEnabled=navigator.cookieEnabled;
var platform=navigator.platform;
var userAgent=navigator.userAgent;
var language=navigator.systemLanguage;

alert('codeName='+ codeName +'\n' +
'appName='+ appName +'\n' +
'cookieEnabled='+ cookieEnabled +'\n' +
'platform='+ platform +'\n' +
'userAgent='+ userAgent +'\n' +
'language='+ language);

}


//可创建三种消息框: 警告框,确认框,提示框

function popupAlert(){
//警告框用 alert()
//alert("警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下警告你一下");

//确认框
/*
var r=confirm("Plaer a button!");
if(r ==true){
alert("You pressed OK!");
}else{
alert("You pressed Cancel!");
}
*/

//提示框
//语法 prompt("文本","默认值")
var name=prompt("请输入你的名字:" , "Bill Gates");
if(name !=null && name !=""){
alert("你输入的文字是: "+ name);
}else{
alert("请输入文字!");
}

}

//计时
function timing1(){
var t=setTimeout("alert('5秒后弹出!')",5000);
}

var c=0;
var t;

//开始计时
function startTime(){
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout('startTime()',1000);
}

//停止计时
function endTime(){
clearTimeout(t);
}


//JS Cookies
function cookieMethod(){
var username=getCookie("username");
if(username !=null && username !=""){
alert("Welcome again "+ username);
}else{
username=prompt("Please enter your name:", "");
if(username !=null && username !=""){
setCookie('username',username,365);
}
}

}

//设置cookie

function setCookie(c_name,value,expiredays){
var exdate=new Date();
exdate.setDate(exdate.getDate() + expiredays);
//document.cookie=escape(c_name) + "=" + escape(value) + ";expires="+exdate.toGMTString());
document.cookie = escape(c_name) + '=' + escape(value) +';expires=' + exdate.toGMTString();
}


//获取cookie

function getCookie(c_name){
var showAllCookie = '';
if(!document.cookie == ''){
var arrCookie = document.cookie.split('; ');
//用spilt('; ')切割所有cookie保存在数组arrCookie中
document.getElementById('div1').innerHTML='arrCookie='+arrCookie + ' Cookie='+document.cookie + ' arrCookie.length='+arrCookie.length;
var arrLength = arrCookie.length;
for(var i=0; i<arrLength; i++) {
showAllCookie += 'name:' + unescape(arrCookie[i].split('=')[0]) + ' value:' + unescape(arrCookie[i].split('=')[1]) + '<br>';
}
}
return showAllCookie;

}


//删除Cookie
function deleCookieMethod(){
if(document.cookie != '' && confirm('你想清理所有cookie吗?')) {
var arrCookie = document.cookie.split(';');
var arrLength = arrCookie.length;
var expireDate = new Date();
expireDate.setDate(expireDate.getDate()-1);
for(var i=0; i<arrLength; i++) {
var str = arrCookie[i].split('=')[0];
document.cookie = str+ '=' + ';expires=' + expireDate.toGMTString();
}
}
}

</script>
</head>

<body οnlοad="startTime()">
<div id="div1"></div> <br />

<p>
<input type="button" value="开始计时" οnclick="startTime()"/>
<input type="text" id="txt">
<input type="button" value="停止计时" οnclick="endTime()"/>
</p>
<button οnclick="windowMethod()">JS Window对象</button>
<button οnclick="window.open();">打开新窗口</button>
<button οnclick="window.close();">关闭窗口</button>
<button οnclick="screenMethod()">JS Screen</button>
<button οnclick="locationMethod()">JS Location</button>
<button οnclick="historyMethod()">JS History</button>
<button οnclick="navigatorMethod()">JS Navigator</button>
<button οnclick="popupAlert()">JS popupAlert</button>
<button οnclick="timing1()">JS timing</button>
<button οnclick="cookieMethod()">JS Cookies</button>
<button οnclick="deleCookieMethod()">JS Delete Cookies</button>
</body>
</html>


@yinhuidasha.longyilu.tianhequ.guangzhoushi.guangdongsheng
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Nuitka 1.0.6 是一种高效的编译器,可将Python代码编译为高效的C代码。它是免费且开源的,并支持各种平台和操作系统,如Windows、Linux和MacOS等。如果您需要加速Python代码的执行速度,或者想要将Python代码转换为可执行文件,则可以考虑使用Nuitka。 要下载并安装 Nuitka 1.0.6,您可以前往其官方网站或GitHub页面找到相关的下载链接和说明。在下载完成后,您可以按照说明安装和配置Nuitka,并使用它来编译Python代码。在编译过程中,Nuitka将自动将Python代码转换为C代码,并使用gcc或者Clang等C编译器生成可执行文件或动态链接库。 总而言之,Nuitka 1.0.6是一种强大的工具,适用于需要高效执行Python代码或将Python代码转换为可执行文件的人。它的安装和使用都相对简单,但使用前最好先了解一些基础的编译知识。 ### 回答2: Nuitka 1.0.6 是一个开源的 Python 代码编译器,可将 Python 代码转换为 C 或 C++ 代码,并生成可执行文件。您可以通过以下步骤下载 Nuitka 1.0.6: 1. 打开您的互联网浏览器,进入 Nuitka 的官方网站。 2. 在官方网站的首页或下载页面,找到 Nuitka 1.0.6 的下载链接。 3. 点击下载链接,将会开始下载 Nuitka 1.0.6 的安装文件。请耐心等待下载完成。 4. 下载完成后,找到下载好的安装文件,可能是一个压缩文件,比如 .zip 或 .tar.gz 格式。 5. 解压缩下载的文件,可以使用压缩软件如 WinRAR、7-Zip 等。解压缩后会得到一个文件夹。 6. 进入解压缩后的文件夹,找到其中的安装文件或可执行文件。 7. 双击运行安装文件或可执行文件,按照安装向导进行安装或直接运行应用程序。 8. 安装或运行过程可能需要管理员权限,请按照提示进行操作。 9. 完成安装或运行后,您就可以使用 Nuitka 1.0.6 编译和生成 Python 程序的可执行文件了。 注意:在下载和安装软件时,请确保从官方网站或可信的软件源下载,以免下载到恶意软件或安全问题。此外,建议根据您的操作系统和需求,选择适合的版本和下载选项。 ### 回答3: 要下载 Nuitka 1.0.6,可以按照以下步骤进行: 1. 打开 Nuitka 官方网站(https://nuitka.net/)。 2. 寻找网站上的下载页面或者下载链接。 3. 找到 Nuitka 1.0.6 的版本,可能会根据不同的操作系统有不同的下载选项。 4. 选择适合你操作系统的下载选项,比如 Windows、Linux 或者 macOS。 5. 单击下载链接,开始下载 Nuitka 1.0.6 的安装文件。 6. 保存文件到你想要的目录,通常下载文件会保存在默认的“下载”文件夹中。 7. 下载完成后,双击安装文件进行安装。 8. 按照安装程序的指示完成安装过程。 9. 安装完成后,你就可以开始使用 Nuitka 1.0.6 了。 通过以上步骤,你应该能够成功下载并安装 Nuitka 1.0.6 版本。请注意,在下载和安装软件时,要选择可信的来源和下载地址,以确保软件的安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值