老师,ppt当中有个“var a;在这个例子当中a表示一个变量,a是变量的变量名”,请问var是什么?为什么老师在第三节课中提到var是变量?谢谢老师
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> var num=10; window.name='var num=10;'; </script> </body> </html>
与主代码在同一级目录下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>window对象</title> </head> <body> <button>跨域传输</button> <script> // open('http://www.baidu.com'); // close(); // var but =document.querySelector('button'); // but.onclick=function(){ // var iframe = document.createElement('iframe'); // iframe.src='name.html'; // iframe.style.display='none'; // document.body.appendChild(iframe); // iframe.onload=function(eve){ // var iframeWindowName = eve.target.contentWindow.name; // console.log(iframeWindowName); // } // } var but= document.querySelector('button'); but.onclick=function(){ var iframe= document.createElement('iframe'); iframe.src='name.html';//加载保存了信息的页面 iframe.style.display='none'; document.body.appendChild(iframe); //当iframe加载完毕,意味着window.name的内容已经被赋予完毕 iframe.onload=function(eve){ var iframeWindowName=eve.target.contentWindow.name; // console.log( iframeWindowName); eval(iframeWindowName); console.log(num); } } </script> </body> </html>
跟着老师的代码敲的,无奈报错,于是把老师的代码拿过来 仍然报错,如图
.(.); =((){ .(.); (.==){ clearIntervar();} },);
老师,我这个是按照视频打的,但是我这个一直都是无限循环,这是怎么回事呢?
//方法一 var str = '你好,弗兰克!再见,弗兰克!'; var newStr = str.replace(/[弗][兰][克]/g,'(frank)'); console.log(newStr); //你好,(frank)!再见,(frank)! //方法二 var str1='你好,弗兰克!再见,弗兰克!'; var newStr = str.replace(/弗兰克/g,'(frank)'); console.log(newStr); //你好,(frank)!再见,(frank)!
老师,视频中讲的是方法一 ,方法一和方法二的输出结果是一模一样的,那么方法二可行吗这种写法??
这个undefined的写法不严谨啊,
var arr=[1,23,4,5,undefined,7];
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>函数类型</title> </head> <body> <script> function baozi(mianfen,dadou,yancong){ console.log(mianfen); console.log(dadou); console.log(yancong); return'包子'; } baozi("面粉","大豆","洋葱"); </script> </body> </html>
老师我想问一下 我的为什么返回的不是包子,而是后面的面粉、大豆和杨葱呢
老师,我想实现一个点击事件,点一下div的颜色就改变,这个用目前学到的知识能不能实现
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>106.window对象的name属性</title> </head> <body> <button>跨域传输</button> <script> //console.log(num); //如果想要获取一个页面内的信息,那么必须先加载 var but= document.querySelector('button'); but.onclick=function(){ var iframe= document.createElement('iframe'); iframe.src='106中的page.html';//加载保存了信息的页面 iframe.style.display='none'; //加载过来不显示 document.body.appendChild(iframe); //当iframe加载完毕,意味着window.name的内容已经被赋予完毕 iframe.onload=function(eve){ var iframeWindowName=eve.target.contentWindow.name; console.log( iframeWindowName); console.log(typeof iframeWindowName); eval(iframeWindowName); //解析字符串 console.log(num); } } </script> </body> </html>
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <script> var num=10; window.name='var num=10;'; window.name='var num=[1,2,3];'; //可以是数组 window.name='var num={age:22};';//对象也可以 </script> </body> </html>
老师我按视频中的代码敲的,为啥会出现这种结果,这是什么情况,浏览器的版本不同吗???
按照老师的写法为啥,输入内容,右键点击并不能搜索,而只是跳转到百度首页 ??
老师,读取属性
console.log(obj['name']);
用这个方法怎么读取函数的
var timer1=null; var timer2=null; var timer3=null; timer1=setInterval(function(){console.log('这是第1个定时器')},2000); timer2=setInterval(function(){console.log('这是第2个定时器')},2000); timer3=setInterval(function(){console.log('这是第3个定时器')},2000); console.log(timer1); console.log(timer2); console.log(timer3) //clearInterval(2); clearInterval(timer1);
还有,按老师的代码,为啥视频中先输出的是123 ,而我这先输出的是234 ,这是什么情况
setInterval(function(){console.log('这是第1个定时器')},2000); setInterval(function(){console.log('这是第2个定时器')},2000); setInterval(function(){console.log('这是第3个定时器')},2000); clearInterval(2); clearInterval(1);
老师,我这代码清除 1 2 为啥输出的是 2 3 ,不是应该只 输出3 吗
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>DOM0级事件</title> </head> <style> .div1{ width: 200px; height: 200px; background-color:pink; } .div2{ width: 100px; height: 100px; background-color:blue; margin: 25px auto; } </style> <body> <div class="div1" >div1 <div class="div2">div2</div> </div> <script> var div1=document.querySelector('div1'); var div2=document.querySelector('div2'); /* DOM0级事件 描述:在js脚本中,直接通过on+事件名的方式绑定的事件称为DOM0级事件 语法:元素.on+事件名=function(){} */ div2.onclick=function(){ console.log('这是div2'); } </script> </body> </html>
老师,为什么我的会提示这个错误
var alt=""; for (var i=1;i<=5;i++){//控制行 var blank=""; for(var j=1;j<=5-i;j++){//控制空白三角形 blank+=" "; } var starts=""; for (var m=1;m<=2*i-1;m++){ starts+="*"; } alt+=blank+starts+"\n"; } document.write(alt);
老师,我想问一下,最后一步用document.write(alt) 为什么不能显示图案出来呢,然后用console.log(alt)却又可以?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637