我正在尝试返回c =然后将其写入输入字段并提交值。
var x = window.external.menuArguments.location.href; // IE Get URL Code
alert(x);
// http://site.com/design/page.html?c=235783&p=irol-IRHome
// this code below populates a html pop that is created on popup.
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
var html = new String(rng.htmlText);
var ops = "width=650,height=410,status=0,toolbar=0,menubar=0,resizable=1";
viewSourceWin = parentwin.open("about:blank","viewselectionscr",ops);
// open document for further output
viewSourceWin.document.open();
viewSourceWin.document.write("$(document).ready(function() {");
viewSourceWin.document.write("load = ?;");
viewSourceWin.document.write("$('#cmid').val(load);$('.go').click();");
viewSourceWin.document.write("});");
viewSourceWin.document.write("<input id='cmid'/><button class='go'>Go</button>")");
答案 0 :(得分:1)
您需要location.search,例如:
var query = window.location.search.substring(1); // use substring to remove the leading '?'
var keyValues = query.split('&'); // split apart
var params = {};
for (var kv in keyValues) {
var parts = kv.split('=');
params[ parts[0] ] = parts[1];
}
var c = params['c'];
//... do whatever you need
当然有一个jquery插件或三个以及一些更高级的正则表达式,你也可以使用。