简体   繁体   中英

window.location.replace not working with some urls

I'm trying to do a JavaScript redirect.

I'm trying to do it like this:

window.location.replace('https://ad.doubleclick.net/ddm/jump/N5371.1920006AAPLUS/B10640187.141970298;sz=1x1;ord=[timestamp]?')

This returns undefined and does nothing.

However, in the exact same context

window.location.replace('https://ad.doubleclick.net');

works just fine. What gives?

Sorry for the ad tag; it's the only URL I've found that doesn't work so far.

如果您的URL提供204 No Content (告诉浏览器什么也不做),则会发生这种情况。

That's because your url trails is not valid. If you try it with just ' https://ad.doubleclick.net ' it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM