javascript - Script URL with pound sign (hashtag) cut off when inserting in DOM -


from external resource urls trackers need execute/load in dom, url # in it, gets cut off after pound sign, whatever try. have no control on these urls come 3rd party, want able load url without modification it. example url: http://www.example.com/resource.js?param1=testvalue#a=b&c=d&f=g&js=.js
when executed url changes into: http://www.example.com/resource.js?param1=testvalue

the code i'm sharing works in cases, except url above.

original code:

$('#myelement').append('<script language="javascript1.1" src="' + url + '"></script>') 

what tried too:

var s = document.createelement("script") s.type = "text/javascript" s.src = url $('#myelement')[0].appendchild(s) 

and other variations appending child, tried insert image element too, didn't work either.

the other post find on suggests browser (jquery ajax call on url pound (number) sign )...seems logical, company we're not first client of company...

so need encode url don't let browser interpret raw parameters. can have on post encode url in javascript? . , maybe check little bit documentation understand why need that.(https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/encodeuricomponent). jsut have redirect encodeuricomponent(url) or when add parameters (link + encodeuricomponent(params)).


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -