设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 1970|回复: 0
打印 上一主题 下一主题

javascript 相对路径转绝对路径 [复制链接]

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

跳转到指定楼层
1#
var resolve = function() {
	var iframe = document.createElement('iframe');
	iframe.style.cssText = 'position:absolute; left:-1000px; top:-1000px;';
	document.body.appendChild(iframe);
	return function(path1, path2) {
		iframe.contentWindow.document.write("<html><head><base href='"+path1+"'/></head><body><a href='"+path2+"'>a</a></body></html>");
		return iframe.contentWindow.document.body.firstChild.href;
	};
}();


resolve('http://www.linjunhai.com/blog/article.asp?id=183', '../a/b/c.html');
// [url]http://www.linjunhai.com/a/b/c.html[/url]
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0
您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-4-20 04:11 , Processed in 1.099092 second(s), 13 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部