On Tue, 24 Feb 2015 15:04:10 +0100, Brenton Horne <[email protected]> wrote:

I have done some research into JavaScript, which is what inspired me to ask this question because I knew that quotation marks "" substitute variable names with their variable value leaving the rest of what is in them as a string, whereas apostrophes like ' ' render everything inside them as a string. So I initially tried to define the page name variable using:

That is true in some languages (for example PHP), but not in JavaScript. There is no variable substitution at all there, and both kinds of quotes work exactly the same.


|var  page=  mw.config.get(  'wgPageName'  );|

then I defined the URL string |'http://127.0.0.1/mediawiki/index.php/Special:PrefixIndex/'"page"|

You would need something like:

var url = 'http://127.0.0.1/mediawiki/index.php/Special:PrefixIndex/' + page;

The "+" operator serves as both addition (for numbers) and concatenation (for strings).

Note, however, that the above will not work if your page title contains a question mark – everything after the '?' will be treated as PHP query parameters by the server, rather than page title. The simplest way to fix this is to use query parameters yourself:

var url = 'http://127.0.0.1/mediawiki/index.php?title=' + encodeURIComponent( 'Special:PrefixIndex/' + page );


--
Bartosz Dziewoński

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to