javascript - location.href return strange URL -


i'm using location.href full url exists in browser address bar.
provide more detail, it's important note our service has js file included in our customers sites. js file generate full url of applicant.

i thought url somehow previous url redirected real domain, how should prevent action?

the line of js code generate link iframe's src attribute is:

'http://sd.domain.ir/index.php?r=' + math.floor(math.random() * (100000000 - 0 + 1)) + 0 + '&ref=' + ((window.btoa) ? btoa(location.href) : 'ie') + '&responsive=' + ((document.queryselector('meta[name="viewport"][content*="width=device-width"]')) ? 'yes' : 'no') + '&params=' 

examples of applicant ua:
mozilla\/5.0 (linux; u; android 4.3; en-us; huawei g620-l72 build\/huaweig620-l72) applewebkit\/534.24 (khtml, gecko) version\/4.0 mobile safari\/534.24 t5\/2.0 bdbrowser\/6.1.0.4

mozilla\/5.0 (linux; u; android 4.4.3; en-ae; htc_one build\/ktu84l) applewebkit\/534.30 (khtml, gecko) version\/4.0 mobile safari\/534.30

mozilla\/5.0 (linux; u; android 4.3; en-us; gt-i9300 build\/jss15j) applewebkit\/534.30 (khtml, gecko) version\/4.0 mobile safari\/534.30

...

sometimes strange url generated location.href , don't know reason. example:

main url below: http://saten.ir/tag/%d8%a8%db%8c%d9%88%da%af%d8%b1%d8%a7%d9%81%db%8c-%d8%a7%d9%85%db%8c%d8%b1%d8%b9%d8%a8%d8%a7%d8%b3-%d9%81%d8%ae%d8%b1%d8%a2%d9%88%d8%b1/

but url returned location.href below:
http://www.google.com/search?site=&source=hp&ei=mpkewivhkywbsggtxasqbg&q=%d8%a7%d9%85%d9%8a%d8%b1%d8%b9%d8%a8%d8%a7%d8%b3+%d9%81%d8%ae%d8%b1%d8%a7%d9%88%d8%b1&oq=%d8%a7%d9%85%d9%8a%d8%b1%d8%b9%d8%a8%d8%a7%d8%b3+%d9%81%d8%ae%d8%b1%d8%a7%d9%88%d8%b1&gs_l=mobile-gws-hp.3...4752.15339.0.16567.0.0.0.0.0.0.0.0..0.0....0...1c.1.64.mobile-gws-hp..0.0.0.ufwl1tf4kdm#scso=uid_wb6zrwaghj0klaxlja8j8w_10:2120,uid_wb6aqqagpzkklnwfpgmnba_10:2120

try this

var myurl = location.origin + decodeuricomponent(location.pathname); 

basically same location.href should works


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -