[英]What is wrong with my javascript for a browser I would like to create?
I know you people will think I am insane, and thus an idiot, but I really have a serious question, well at least to me. 我知道你们会认为我疯了,因此是个白痴,但我确实有一个严肃的问题,至少对我来说是这样。 What is wrong with my javascript for a browser I would like to create?It will not open the URL in the iframe.
我要创建的浏览器的JavaScript有什么问题?它将无法在iframe中打开URL。 I am creating an html source file with some javascript to split a "get" url,and echo the resulting variable into an iFrame.
我正在使用一些JavaScript创建html源文件,以拆分“获取”网址,并将生成的变量回显到iFrame中。 I wanna use Webkit as the rendering engine, so I'm using Google Chrome to create an application shortcut.
我想使用Webkit作为呈现引擎,所以我正在使用Google Chrome创建应用程序快捷方式。 Yes, I know it will require google chrome, but this is just a test.
是的,我知道这将需要Google Chrome,但这只是一个测试。
function goTo(){
var urlb = window.location.href;
var urla = urlb.split('localhost/browser.html?url=');
var urlc = urla[1];
var urld = urlc.replace("+"," ");
var urle = urld.replace("%3A ",":");
var urlg = urle.replace("%2F","/");
var url = urlg;
document.getElementByID('url').innerHTML="<iframe src=' . url . "'width='100%'
height='90%'></iframe> Opened:" . url ."</div>";
}
This is the javscript function to open the url. 这是打开URL的javscript函数。 I am pretty sure you would think that the html is just a simple input form and the blank Iframe, which it is.
我敢肯定,您会认为html只是一种简单的输入形式,而空白的iframe是这样。
Please help me if you can. 如果可以,请你帮助我。
When you are trying to get the URL, you want to use decodeURIComponent()
. 当您尝试获取URL时,您想使用
decodeURIComponent()
。 Don't make up your own function to unescape the data. 不要组成自己的函数来对数据进行转义。 Also, get the query string parameters properly.
另外,正确获取查询字符串参数。 See this StackOverflow post: https://stackoverflow.com/a/901144/362536
请参阅此StackOverflow帖子: https ://stackoverflow.com/a/901144/362536
Now that you have the proper URL, don't simply inject it into your HTML. 现在您有了正确的URL,不要简单地将其注入HTML中。 You're opening yourself up to security troubles, and a broken browser when you run into characters you don't expect.
您将面临安全隐患,当浏览器遇到意外字符时,浏览器将损坏。 Create the iframe, then set its attributes programmatically.
创建iframe,然后以编程方式设置其属性。 https://stackoverflow.com/a/710347/362536
https://stackoverflow.com/a/710347/362536
Finally, fix your syntax errors. 最后,修复语法错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.