檢測第三方鏈接頁面跳转提示

<p>即将跳转至新页面,请稍等...</p>
<script>
	// 定义跳转目标页面的 URL
	const targetUrl = 'http://example.com';
 
	// 定义跳转等待时间(单位:毫秒)
	const waitTime = 3000;
 
	// 检测是否是第三方链接
	function isThirdParty(url) {
		const a = document.createElement('a');
		a.href = url;
		return a.hostname !== window.location.hostname;
	}
 
	// 等待指定时间后跳转到目标页面
	setTimeout(() => {
		if (isThirdParty(targetUrl)) {
			if (confirm('这是一个第三方链接,是否确认跳转?')) {
				window.location.href = targetUrl;
			}
		} else {
			window.location.href = targetUrl;
		}
	}, waitTime);
</script>

jquery 反轉對象數組

var arr = [
  { id: 1, name: 'Tom' },
  { id: 2, name: 'Jerry' },
  { id: 3, name: 'Spike' }
];

var reversedArr = $.map(arr, function(obj, index) {
  return arr[arr.length - 1 - index];
});

console.log(reversedArr);