url-parameters

Get page URL parameters from a service worker

假如想象 提交于 2019-12-22 00:26:38
问题 How do I get page URL with parameters from a service worker? I have tried self.registration.scope but that doesn't include the parameters. 回答1: I'm not clear as to whether you're asking about getting the service worker script's URL, or the URLs of all of the client pages that are open under the service worker's scope. So... here's how to do both: // Get a URL object for the service worker script's location. const swScriptUrl = new URL(self.location); // Get URL objects for each client's

How to use a PHP switch statement to check if a string contains a word (but can also contain others)?

早过忘川 提交于 2019-12-21 03:12:27
问题 I'm using a PHP switch to include certain files based on the incoming keywords passed in a parameter of the page's URL. The URL, for example, could be: ...page.php?kw=citroen%20berlingo%20keywords Inside the page, I'd like to use something like this: <? switch($_GET['kw']){ case "berlingo": include 'berlingo.php' break; case "c4": include 'c4.php'; break; } ?> What I want to do in the first case is include the berlingo.php file if the keyword parameter contains berlingo , but it doesn't have

AngularJS: Read route param from within controller

喜你入骨 提交于 2019-12-20 09:39:54
问题 How can a parameter from an URL be read within an AngularJS controller? Let's say I have an URL like http://localhost/var/:value and I want the value to be stored in a variable within the controller for the /var/:value URL. I have tried using $routeParams.value and $route.current.params.value but $routeParams is undefined at the beginning and $route doesn't work. 回答1: The problem is that you probably inject $routeParams or $route in a controller that is run before a route change has occurred,

MediaWiki URL parameters without values

亡梦爱人 提交于 2019-12-19 06:14:10
问题 The query part of a URL seems to consist of key-value pairs separated by & and associated by = . I've taken to always using jQuery's $.param() function to URL-encode my query strings because I find it makes my code more readable and maintainable. In the past couple of days I find myself calling the MediaWiki API but when cleaning up my working prototype with hard-coded URLs to use $.param() I noticed some MediaWiki APIs include query parameters with keys but not values! api.php ? action=query

How do you add query parameters to a Dart http request?

此生再无相见时 提交于 2019-12-18 18:53:26
问题 How do you correctly add query parameters to a Dart http get request? I been unable to get my request to respond correctly when trying to append the '?param1=one&param2=two' to my url, yet it works correctly in Postman. Here's the gist of my code: final String url = "https://www.myurl.com/api/v1/test/"; String workingStringInPostman = "https://www.myurl.com/api/v1/test/123/?param1=one&param2=two"; Map<String, String> qParams = { 'param1': 'one', 'param2': 'two', }; var res = await http .get

Regex to get value of a numeric URL parameter?

…衆ロ難τιáo~ 提交于 2019-12-18 04:26:15
问题 In a url like the one below, I'd like to get the value of ProdId. The URL format will always be consistent, as will the parameter name, but the length of the value may change. It will always be numeric. http://www.example.com/page.php?ProdId=2683322&xpage=2 Using PHP what's the fastest way to get it (I'll be processing 10,000's so speed is an issue)? 回答1: PHP has built-in functions for this. Use parse_url() and parse_str() together. Pieced together from php.net: $url = 'http://www.example.com

Struts 2 - Sending mail with embedded URL

ぐ巨炮叔叔 提交于 2019-12-18 04:21:22
问题 For a project for my company, I have to send emails containing embedded URLs, which the user will be prompted to follow. For example, a person registers on the website, and then the Struts2 application sends an email to that person in which there is a URL to confirm the subscription. So far, the form submission, and sending the email (from inside the action), work just fine. The problem on which I'm stuck is that I can't find a way to generate the URL I'd like to embed in the mail body. I

Struts 2 - Sending mail with embedded URL

送分小仙女□ 提交于 2019-12-18 04:21:00
问题 For a project for my company, I have to send emails containing embedded URLs, which the user will be prompted to follow. For example, a person registers on the website, and then the Struts2 application sends an email to that person in which there is a URL to confirm the subscription. So far, the form submission, and sending the email (from inside the action), work just fine. The problem on which I'm stuck is that I can't find a way to generate the URL I'd like to embed in the mail body. I

Send list/array as parameter with jQuery getJson

心已入冬 提交于 2019-12-17 22:34:14
问题 I have the following where I'm trying to send list/array to MVC controller method: var id = []; var inStock = []; $table.find('tbody>tr').each(function() { id.push($(this).find('.id').text()); inStock.push($(this).find('.stocked').attr('checked')); }); var params = {}; params.ids = id; params.stocked = inStock; $.getJSON('MyApp/UpdateStockList', params, function() { alert('finished'); }); in my contoller: public JsonResult UpdateStockList(int[] ids, bool[] stocked) { } both paramaters are

Change URL parameters

拜拜、爱过 提交于 2019-12-16 19:57:03
问题 I have this URL: site.fwx?position=1&archiveid=5000&columns=5&rows=20&sorting=ModifiedTimeAsc what I need is to be able to change the 'rows' url param value to something i specify, lets say 10. And if the 'rows' doesn't exist, I need to add it to the end of the url and add the value i've already specified (10). 回答1: I've extended Sujoy's code to make up a function. /** * http://stackoverflow.com/a/10997390/11236 */ function updateURLParameter(url, param, paramVal){ var newAdditionalURL = "";