简体   繁体   English

我要创建的浏览器的JavaScript有什么问题?

[英]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.

相关问题 我想创建一个循环来浏览我对象的每个属性:this.current.questionnaireProfil JavaScript - I would like to create a loop to browse each property of my object: this.current.questionnaireProfil JavaScript 我想在我的 angular 项目中使用 javascript html 标签,但是 ZD18B8624A0F5F780E2F919Z 可能是什么问题? - I would like to use javascript html tag in my angular project, but angular just ingnores it, what might be a problem? Javascript只需点击两下即可初始化我希望它执行的操作 - Javascript is taking two clicks to initialize what I would like it to do 我在JavaScript中做错了什么? - What did I do wrong in my javascript? 我想使用javascript和json标记我的帖子 - I would like to tag my posts, using javascript and json 我希望我的 javascript 按钮引用外部链接 - I would like my javascript button to refer to an external link 我的JavaScript有什么问题? - What is wrong with my Javascript? 我将如何解决这种曼哈顿天际线/石墙的方法,哪里出了问题? 使用Javascript - How would I fix my approach to this Manhattan Skyline/Stone Wall and where did I go wrong? Javascript 我正在尝试使用 javascript 创建一个绘图应用程序,但它应该发生的 canvas 元素没有响应。 我的代码有什么问题? - I'm trying to create a drawing app with javascript, but the canvas element it's supposed to take place in is unresponsive. What's wrong with my code? 我的JavaScript代码有什么问题 - What is wrong with my JavaScript code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM