如何将字符串对象值应用于变量Ex.
var str='{a:"www"}'
Run Code Online (Sandbox Code Playgroud)
现在如何设置
var obj={a:"www"}
Run Code Online (Sandbox Code Playgroud)
我尝试eval()但不工作
现在大多数浏览器都支持IndexedDB将数据/文件直接存储为File,Blob或ArrayBuffer.
此代码将IDB密钥"File1"保存为文件
<input type="file" id="userfile" />
var a = document.getElementById("userfile");
var b = a.files[0];
Run Code Online (Sandbox Code Playgroud)
现在我们可以使用以下代码直接将此文件保存到IDB
//LocalForage is a library for indexedDB developed by Mozilla
//Note: localforage._config.driver=asyncStorage (IDB method)
function run(){
//"File1" = IDB data table key and b=value
localforage.setItem("File1", b, function(err, value) {
console.log(err)
});
}
a.onchange = function(){
run()
}
Run Code Online (Sandbox Code Playgroud)
此代码将IDB密钥"BlobFile"保存为Blob
mb = new Blob([b],{type:b.type});
function runB(){
localforage.setItem("BlobFile", mb, function(err, value){
console.log(err)
});
}
a.onchange = function(){
runB()
}
Run Code Online (Sandbox Code Playgroud)
我想知道将文件存储到IDB的最佳做法是什么.(文件/斑点/ ArrayBuffer) …
示例:假设当前页面url(window.location.href)是http://example.com/page.html html页面源代码是......
<html><head></head><body>
<script src="http://example.com/script.js?user=Ankit&ptid=18"></script>
</body></html>
Run Code Online (Sandbox Code Playgroud)
现在我需要在script.js中使用'src'变量并且脚本文件script.js应该返回
var a="Ankit"
var b="18"
Run Code Online (Sandbox Code Playgroud)
我们可以在php中使用echo $ _GET之类的东西吗?
如果没有 ,我如何编写以下内容&&?
if(a == 1 && b == 2) { ... }
Run Code Online (Sandbox Code Playgroud)
我可以为操作员创建一个函数吗?