href - append a parameter to current url without javascript - html

My webpage url looks like this:
http://mywebsite.com/show-index/index?limit=100
Where limit defines the number of items to display.
I'd like to add a 'show more' which would basically add 'more=true' to my current url:
http://mywebsite.com/show-index/index?limit=100&more=true
I've tried this:
href='?more=true'
But it overides the parameter limit.
Is there a simple way to do it without using javscript?
Thanks

The best would be to do it by Ajax.
If you really don't want to, just use a link
<a href="http://mywebsite.com/show-index/index?limit=100&more=true"</a>
On PHP side, if you detect $_GET['more']='true', juste change the limit to limit+100 in the link.
The best would be to add some achor as #Bartdude says to do not have to scroll each time the page is reloaded.
Don't forget to upvote and mark as solved if you find this useful :)

Related

How to remove query string from URL using href

Currently, my page URL looks something like so:
https://example.com/eg?page=2
The URL can also sometimes look like:
https://example.com/eg/?page=2
I want to redirect the user to the same page, but without the query string, so that when clicking on a link it will take you to:
https://example.com/eg
I tried using the following href in an anchor tag suggested in this question:
To home
When clicking on the link, it removes the query string like I want when the current page URL is https://example.com/eg/?page=2. However, if the page URL is https://example.com/eg?page=2 it takes me to https://example.com.
Question: Is there some type of directory path (ie url I can use in my href) I can use such that the two above URLs will always remove the query string? I can use javascript, but if a solution without is possible that would be preferred.
Note: I cannot hard code eg into my href url as I'm developing a widget which can sit in different environments, so, eg is subject to change.
A relative link beginning with ? should only modify the query string, so you could use:
Home
Which would direct your example URLs to:
https://example.com/eg?
https://example.com/eg/?
It does include the ? in the final URL, which might not be what you want, but it is a functional option if you don't want to use Javascript.
You can use,
Home
You can also use document.location instead of window.location. But it is not recommended. See here
Apply this script into your a tag.
Home

Changing page title as it appears in MediaWiki category

I've been trying to use DEFAULTSORT to sort pages based on a template parameter instead of the page title. This is how it appears at the top of the template:
{{DEFAULTSORT:{{{Username}}}}}
This is how it appears after the argument is transcluded:
{{DEFAULTSORT:d3xus}}
It would be nice for it to appear in categories as d3xus and not D3xus. There's no change in how the page is sorted because they both begin with the same symbol. Using an extension or magic word, is it possible to change how a page appears when viewed in a category? DEFAULTSORT only changes how the page is sorted with respect to other pages in the same category, but it does not change the page title in the category.
That's actually impossible without a bigger change in the code. There is a task for it in Wikimedia's bug/feature tracking software Phabricator: T19212, but it's actually stalled :(
There is no such thing. If you want to change the page title regardless where it is displayed, you can use $wgCapitalLinks or {{DISPLAYTITLE}}.
Actually it seems there is such a thing: Extension:Semantic Title. It is very hacky though (and you need to install Semantic MediaWiki).
Try this:
Method 1: Add to your MediaWiki site: {{DISPLAYTITLE:d3xus}} and [[Category:d3xus]].
Method 2: https://www.mediawiki.org/wiki/Extension:Semantic_Title

Retrieve all hashes in a page for URL use

I am trying to copy a link from this site (stack overflow), but I like the link to include a hash so when someone clicks on the link they go directly to the answer I would like them to see. How can I find the hashes in a page?
Example:
http://www.blahblah.com/index.php#label
How can I know there is a #label, and how to find it?
The value of the hash is simply the ID attribute of any element in the page.
You can see them in the source or the DOM inspector.
Are you looking for something like this?
var hash = window.location.hash;
There might not be a simple answer for your here. In a pure HTML context (i.e. excluding javascript functionality). The has would reference an anchor on the page like this:
<a name="label"></a>
So you could just look for named anchors.
Now, if you are talking about javascript functionality it gets much more complex. Via javascript you can use a hash tag like that and make it do any number of things (like show a hidden element with id="label", download some content asynchronously based on that hash, etc. So there might not be an easy way to determine allowable values.

Difference between twitter share buttons

I simply want to add couple share button onto my page. And I see that people recommend different ways of doing it:
I see some articles using home?status:
<a href=”http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>” title=”Click to send this page to Twitter!” target=”_blank” rel=”nofollow”>Share on Twitter</a>
and some using share?url:
Tweet
What's the difference?
Your first example simply updates the status with the text you enter. The second example has a lot more functionality.
share?url supports class attributes for the anchor tag. In the anchor tag you can add things like data-related to suggest accounts the user will follow after they share the content or if you don't supply a url it will look for the current url the call is being generated from and share that. It has a lot more functionality vs the dumbed down home?status call.
find more here: https://dev.twitter.com/docs/tweet-button

HTML Link questions

When creating a link i need to find out if i can do the following:
blah
I want it so that if the user clicks on it, it will get the content as we described using ajax
however, i want the search engine to be able to follow the link so that we still get maximum indexing.
I'm pretty sure it should work but would like clarification
Set the href attribute of the link to the static page that you want the search engine to follow, then use the onclick event to do your javascript/ajax request for "human" users. As long as the onclick event returns false, the standard link won't be followed.
A good test of this would be turning javascript off and clicking the link - you should end up with what you want the search engine to see.
You don't need the "javascript:" string in the onclick attribute, it is only necessary if you are putting javascript in the href attribute. You should have something like:
blah
I asked similar question, where I got this answer from pekka:
The best way would be to degrade gracefully, e.g. by using a standard
<a id='mylink' href='xyz.html'>
link that points to the resource that is opened in the popup.
You would then add the JQuery code to the link, causing it to open in the pop-up.
That way, even users that do not have JavaScript turned on can access your popup.
Most Lightbox clones like Thickbox work that way.