Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matdombrock/fix-url-search-parameters-js
URLSearchParams() does not work on mobile for iOS, this is an example of a workaround.
https://github.com/matdombrock/fix-url-search-parameters-js
Last synced: 7 days ago
JSON representation
URLSearchParams() does not work on mobile for iOS, this is an example of a workaround.
- Host: GitHub
- URL: https://github.com/matdombrock/fix-url-search-parameters-js
- Owner: matdombrock
- License: mit
- Created: 2018-06-19T01:40:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-19T01:43:27.000Z (over 6 years ago)
- Last Synced: 2024-11-07T04:44:34.345Z (about 2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fixURLSearchParams.js
URLSearchParams() [https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams] does not work on mobile for iOS, this is an example of a workaround.
```js
if ('URLSearchParams' in window) {
var urlParams = new URLSearchParams(window.location.search);
if(urlParams.has('id')){
var id = urlParams.get('id')
$.ajax({dataType: "json",url: "api.php?id="+id, success: function(result){
//ajax
}});
}
}else{
url = window.location.href;
url = url.split("?id=");
var urlParams = url[1]
if(urlParams != null){
var id = urlParams;
$.ajax({dataType: "json",url: "api.php?id="+id, success: function(result){
//ajax
}});
}
}
```