如何在Javascript中打印出行 [英] How to print out line in Javascript
本文介绍了如何在Javascript中打印出行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想测试此函数的返回值getFileExtension(input.files [0] .name)(我在此处指出要指向该行的注释)我的问题是如何在javascript中打印出该值?谢谢!
I want to test the return value of this function getFileExtension(input.files[0].name) (I have a comment there to point at that line) My question is how to print out that value in javascript? Thanks!
<script>
function getFileExtension(filename) {
var ext=filename.split('.').pop();
return ext
}
</script>
<input type='file' onchange="readURL(this);">
<script>
function readURL(input) {
if (input.files && input.files[0]) {
if (getFileExtension(input.files[0].name)=="png") { // this line is our problem
var reader = new FileReader();
reader.onload = function (e) {
document.getElementById("pdf").innerHTML="<img id='blah' src=" +
e.target.result + " alt='your image' width='450'>"
}
reader.readAsDataURL(input.files[0]);
}
}
}
</script>
推荐答案
您可以通过编写
console.log(value);
大多数浏览器都有一个控制台,您可以通过按 f12
来查看.值将在那里结束.
Most browsers have a console which you can see by pressing f12
. The values will end up there.
如果您使用的是Internet Explorer,请记住要打开开发人员工具(f12),否则会出现错误.
If you are using Internet explorer remember to have developer tools open (f12) or you will get an error.
这篇关于如何在Javascript中打印出行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文