Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript Url Self

Featured Replies

Heres the code first


var options = {

pageUrl: function(type, page, current){



return "portuguesegoods.com/theaquaponicist/gallery/index.php?type=blog&page="+page;



}


}


What i need is for the is to get the url dynamically on each page where the code would be place


But i only need

portuguesegoods.com/theaquaponicist/gallery/index.php?type=blog;


and not

portuguesegoods.com/theaquaponicist/gallery/index.php?type=blog&page="+page;


notes**

The landing page or the page one will not have $_get variable so there will be no "+page on it

but other pages will


Note also the front link changes

so it can be

portuguesegoods.com/theaquaponicist/NEWS(***)/index.php?type=news&page="+page;


or a who different domain


how is this done?


Thanks for your time

Edited by sergRamalli

Hey! I think this is what you're looking for :)

 

window.onload = getURL();

function getURL() {
    
    rawURL = window.location.href;
    if (rawURL.indexOf("&") != -1) slicedURL = rawURL.substring(0, rawURL.indexOf("&"));
    else slicedURL = rawURL;
    console.log(rawURL, " => ", slicedURL);
}

 

window.location.href gets the current URL and then the script verifies that it has a second parameter (i.e page). If there is a second parameter, the URL is trimmed, if not, only the raw URL is returned/ whatever. To implement this in your script copy everything but console.log(), and return slicedURL.

Edited by jakdothtml

 

nice, you could simplify that to just ..

slicedURL = window.location.split("&")[0];

 

Haha, of course. I think I'd tried that first. Couldn't actually get it to work with window.location although window.location.href would work perfectly.

  • 2 weeks later...
  • Author

In the end i found a php solutions before i saw your reply.

Which is a simple as a <?php echo $bah; ?>

But i got a few ajax scripts where this will come in handy thanks

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.