我有一个url作为var,来自带数据的div:
<div data="$firstID-$secondID-$url">
然后我们拆分'数据':
ids = ids.split('-'); var firstID = ids[0]; var secondID = ids[1]; var url = ids[2];
我打开它:
window.open(url, 'opener');
一切正常,但链接包含所有这些字符,并停在“http://domain.com/word”:
http://domain.com/word-word/Product/show/name-name-name-name-(name-name)/case{id-id}
我怎样才能将这个疯狂的链接作为var传递给'window.open'并且仍然很明智?
答案 0 :(得分:0)
ids = ids.split('-');
//get rid of first 2 parts
var urlParts = ids.slice(2, ids.length)
// join the remaining parts back
var url = urlParts.join('-')