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)')
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:
show() is not defined
(4 answers)
Closed 9 years ago.
My question is with regards to the popular book "Eloquent JavaScript."
It seems to be a very popular book and appears to be on most "recommended reading" lists for people that wish to learn JS. After starting to read the book, I can certainly understand why: the author is an excellent writer and has a knack for explaining things in a very clear and concise way. What confuses me are the commands he often calls, in the first little bit he uses
Print("hehehe")
and
Show(sum(range(1,10)))
to add all numbers from 1 to 10. But none of those commands appear to be consistent with other tutorials and dont work when I try to run them.
What the heck is going on?! Has the language changed THAT much since the book was published in 2007?
Thanks guys and I apologize if this questions is a dumb one.
Are you using the web version of the book? He explains in chapter 2:
As the previous examples show, alert can be useful for showing the result of some expression. Clicking away all those little windows can get on one's nerves though, so from now on we will prefer to use a similar function, called print, which does not pop up a window, but just writes a value to the output area of the console. print is not a standard JavaScript function, browsers do not provide it for you, but it is made available by this book, so you can use it on these pages.
A similar function, also provided on these pages, is show. While print will display its argument as flat text, show tries to display it the way it would look in a program, which can give more information about the type of the value. For example, string values keep their quotes when given to show:
This question already has answers here:
How to hide html source & disable right click and text copy?
(21 answers)
Closed 9 years ago.
I wonder how to hide the source code of a web page. This is an example of webpage with hidden source (right click -> view page source). Any ideas or suggestions?
UPDATE I fully agree, that fully hiding HTML source is impossible, otherwise the browser could't parse it. Using tools like FireBub etc. will show you the source. The interesting in the example above in that on "show source code" the displayed page does not match the output.
Now I understand it is just another kind of technology used here - XSLT.
Thanks for your replies!
If your page is generated dynamically (by Javascript), then it using View Source will not show anything (or very little, anyway). I suspect that's how your example is doing it.
Bear in mind that any page generated this way will still be visible by using a code inspector such as Firebug. So as #Brad M says, this will only stop people who don't really know what they're doing.
If you build the entire page in Java or Flash (or something similar like Silverlight I guess) then it's a lot harder for someone to find out what the source code is (though Java is pretty easy to decompile)
There is no way to hide your code from a client that must execute the code.
Your example just did some trick to prevent right-clicking and stuff. But eventually you can get your way around.
For interpreted language such as javascript, the following adage is true.
" Lock on the door is only for the one who don't care. If there comes thief, most of the time he is already prepared."
All you can do to prevent is obfuscating your code. That will prevent it for some time. But remember, if they are going to crack it, it is not unstoppable. The basic thing to remember is: your script is going to run on the client side and is "INTERPRETED" by browser. In these days, when there are few tools that can create source code from compiled file, the thought of hiding javascript code is even not thinkable. This How can I obfuscate (protect) JavaScript? can help you on how to do it.
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.
Basically this is the first time when i ASK A QUESTION on stackoverflow. Anyway i will really appreciate if someone can point me to some direction about creating an simple product catalog app using html5+xml+js.
Well the structure is the following:
A: Home page >click> Product Categ >click> List of Products >click> Product Page Description
I'm not sure how shall i create the dynamic pages for the products to be able to extract all the products description from XML whenever click on any of product from the list page.
For example i have 10 products on the page, when i click on product X, an dynamic page with the product X 's (image, description, price) to be created, and so on.
I hope all of these things make sense for you and thanks a lot for your precious time.
For reading XML files using JavaScript, check answers from this question. For HTML5 and JavaScript in general I suggest you to check tutorials for some basics:
JavaScript - http://www.w3schools.com/js/default.asp
HTML5 - http://www.w3schools.com/html/html5_intro.asp
You can also check jQuery library tutorial. And here is jQuery's website.
I think that you should read some basics to learn how to look for more in the web and search for "how-to" connected with specified things you want to do and still don't know where to start.
EDIT:
If you want to check something that you'll need exactly at the beginning, you can check this documentation of addEventListener JavaScript method that will allow you to set action that will be invoked when particular event of the element fires. You can also check links connected to jQuery I mentioned above - jQuery is JavaScript library that makes writing JS simplier. But with both JavaScript and jQuery you have to spend some time reading documentation to know what you can do and how to achieve it.