This question already has answers here:
How do I modify the URL without reloading the page?
(20 answers)
Closed 9 years ago.
I've found a lot of questions about changing the url (without reloading).
Some answers were - use plugins, use location.hash ..., or with reloading
But none of them worked for me.
On website I have a dropdown menu, and on its change the url parameter should have changed.
So what I'm trying to do is:
I want to change: www.foo.com?country=Germany into www.foo.com?country=Slovenia without reload.
Is what I am trying to achieve even possible?
You can in newer browsers; in older ones, you can only change the hash. This seems like a good article on the topic:
http://html5doctor.com/history-api/
What you are looking for is the History API HTML5 provides. It comes with functionality like history.pushState(...), history.popState(...), which lets you dynamically change the URL without having to assign a new URL altogether.
It is used by many sites, including, I suspect, Facebook itself, where if you open a chat box, and navigate between pages, the chat box doesn't reload. It means that all new content are being fetched through Ajax, but then the URL won't change, would it? But it does. I think they do it through history.pushState(...), where you just push a new state into the History stack, and it changes only a certain part of the page. You will find an excellent tutorial here.
Related
This question already has answers here:
How to handle JavaScript being disabled in AngularJS
(2 answers)
Closed 8 years ago.
I have learned angular.js, and it's awesome , i'm impressed. i want to use it in my website, but what if our some of user has disabled JavaScript on there browser, they should still gonna see my website content ?????. i'll appreciate your help.
In most cases when js is required, you should add noscript which will be displayed when js is disabled. In that tag you need to warn user that he/she should enable js.
In addition to other answer, I am quoting from Angular book:
Not everyone’s browser supports JavaScript. Let everyone see all of your content and use your app without needing to execute code in the
browser.
The world has changed since these concepts were born. Point #1 is no
longer true for any interesting population. If you’re running a
browser without JavaScript, you’re rele‐ gated to sites created in the
1990s
Or make a div with a warning/notice text (maybe in center of page), and hide that div in js (first thing in your code)
So, if the user does not have js enabled, they will see the nice warning
This question already has answers here:
can view source be disabled by a website?
(6 answers)
Closed 8 years ago.
Actually I want to protect my source code of my website from everybody.
so I want to disable all sources of finding the code like: Ctrl+U, Ctrl+Shift+I,F12 and menu of browser.
It is impossible to hide your source code. You could install a script to prevent right-clicking or encrypt your code with JavaScript, but that won't stop anyone that knows anything about web development from finding it.
This will never work, and your effort is better spent elsewhere.
At the very least, a user can use a web proxy like Fiddler to easily retrieve the source code.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I update the title of the tab in the same way GMail/Facebook does?
How is it possible to update my browser title value, like Facebook and Yahoo, to show a number that represents notifications/pending items/new messages etc.
Right now, my Facebook page title/tab reads [ (3) Facebook ], which indicates I have 3 unread notifications.
How is this possible? I reckon it uses JS and AJAX but I maybe wrong. Has anybody got any snippets, links or suggestions that will get me started in this?
It's a really nice feature but don't seem to find many websites using it, neither can I find any decent tutorials or examples.
Many thanks
It's just a property of the document object
document.title = "some string";
Use whatever logic you like to determine what information you want to put in there.
Be aware that it will produce some really odd bookmark names.
You just need to change title of your page using javascript.
if you are using jquery, it is as simple as -
$('title').text('someText (3)')
This question already has answers here:
Hiding the address bar of a browser (popup)
(11 answers)
Closed 4 years ago.
How can I hide the location/address bar of popup window created using JS ? am attaching a image where I marked the place wanted to be hidden.
Is it possible ? I use the below script for this.
var ctr=0;
function openpopup(popurl){
var winName = "New_"+(ctr++);
winpops=window.open(popurl,winName,"height=300,width=500,top=300,left=500,scrollbars=yes,resizable")
}
and used this to call onClick='openpopup(this.href);return false;'
Please help me for the same.
You cannot hide the address bar in modern browsers. That is a security measure. The user must always know on what page he is.
Also in that address bar is shown what type of page he is in (HTTP or HTTPS) and information of that webpage if it is secure.
So, sorry, but you cannot do that.
you can use a modal dialog. Not exactly a pop up, but it will open another container. Like an overlay. You see people doing this a lot with images, but you can also use this for html. There are a ton of plugins for jquery.
Heres one with some examples though:
http://jquery.com/demo/thickbox/
I personally like http://fancybox.net/
Only problem is you can't use ajax to call another website, but you can create a page in php or whatever and get the contents of another page and then return that in ajax.
you would want to use something like curl for this.
Forget window.open(). Use jquery ui or jquery tools overlay instead.
A js popup window will work.
You could have a generic page that has an embedded iframe to hide the actual page. Would be a little tricky to pass the right data though. Not really worth it imo.
This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
How does Google achieve the fading effect on the home page?
Hi All,
If you visit Google, notice that when the page loads it is very sterile. Upon moving the mouse many elements of the web page now appear in front of you.
How is this done? I think that it is pretty neat.
Is it AJAX?
No it's not AJAX. It is regular JavaScript.
You may want to check the following post:
How does Google achieve the fading effect on the home page?
Technically, no, it's not AJAX.
AJAX officially stands for Asynchronous Javascript And XML, and colloquially refers to any communication between the browser and the web server without a full page load. Those elements are already on the page from the initial page load, and are simply revealed via Javascript (not retrieved from the server).
Any major Javascript effects library can achieve the effect you describe. See e.g. jQuery and Scriptaculous.
It's not AJAX. Ajax is this.
What you're seeing is probably a mix of CSS/Javascript animation techniques. One example can be found on this CSS Animation page from the webkit site
Have a look at jQuery, they have a function called fadeIn.
That is not what Google is using, but it is (probably) the simplest way you can recreate it.
Also, AJAX stands for Asynchronous JavaScript And XML, which is just another (friendlier) name for XMLHttpRequest. XMLHttpRequest is a way of sending data to and from the server without refreshing the entire page. When you view images in an album on Facebook and click on it, it loads the new image witohut refreshing the page. That is AJAX. Google (and jQuery's fadeIn) are what used to be called DHTML (Dynamic HTML), that is, clever JavaScript programming.
This is done using regular Javascript.
Google uses the mousemove event to find out when the mouse moves, and the setTimeout function to create a timer that gradually fades in the content.
This can be done by using CSS+Javascript, changing the value of opacity (for non-IE browsers) or the opacity level of the DXImageTransform.Alpha filter (IE only), through a setInterval().
Please try to understand what AJAX is before making questions like this!
If you knew what ajax was you would know that the fade in of the options in google has nothing to do with AJAX