Going to home page doesn't load the page in Polymer - polymer

When I go back to the home page(Either by Clicking on the home page icon or using back button) the constructor/ready methods are not beings called meaning that page is not loaded. It is loaded only once i.e either on refresh or when I enter the url again. Why is this happening?

Yes, a page loads one time. If you want a way to check if page is now in view, you can try adapting the _visibleChanged observer from the Shop app.

Related

Is there a way to avoid refreshes of a page load in a web application?

I have a web application using Primefaces 8.0 and JSF 2.2 and the way I have users navigate to instances of the application is by an HTML page with links like the following:
Always opens in the same window
This makes sure that if the user clicks the link a second time, it simply navigates to the tab they already have open. But the browser(chromium in this case) also forces a refresh of the tab every time this link is clicked! Is there any way to avoid this forced refresh?

How to mentain navigation stack in html

i have several pages in in my application
suppose
a.html,b.html,c.html
and user can navigate from one page to another frequently but when user want to go back and when it click to cancle button he should be automatically redirect to the previous page which was accessed by him.is there any solution for it?
Sounds like you simply want to emulate the browser's back button. This can be done with javascript:
window.history.back();

how to change URL dynamically in HTML5

I'm creating single HTML5 page using bootstrap. I have some menu items like services, portfolio etc. When I click on one of these menu items, it scrolls down and display that particular section but it does not change the url.
for example:
suppose if I opens website, index.html will open. now if I click on "portfolio" link, it scrolls down and display the section "portfolio" but it does not change URL like index.html#portfolio. It remains index.html
refer: www.nuabikes.com/#/home
when you open this site, click on one of the menu item and check the url, it changes automatically. And also when page is scrolled down the URL changes automatically.
I want to add this feature in my page.
When you change the content with Javascript and you want the change to reflect in the address. Its called routing, check it up.
Basically you have three options:
Use a framework such as angularjs or ember who does the routing for you more or less
Us a Jquery plugin that does some this. Such as http://www.asual.com/jquery/address/
Handle the change yourself. See this for reference: Updating address bar with new URL without hash or reloading the page

Stop refreshing a specific div when browsing

I'm working on my website where I have a music player. The annoying part is that when I browse to another page the player stops and starts from begining...
What I want is to have a persistent music player. So how can I make the div that contains the music player to be static when browsing to another page?
The website: demo(dot)zdringhi-art(dot)com
Thanks!
WEB is stateless.
So if you move to another page there is no way for a div to remain the same.
Although what you can do is that... Hmm as follows.
Have a single page and have your div in there.
Then the other part of the page is loaded via ajax.
also when a link is clicked only parts of pages will be loaded.
Seems too much of coding , but is the only feasible option.
For eg take facebook
Gurav shah is correct, the web is stateless so if you are changing pages you only have a few options for this.
Frames, yes before anyone shouts this is what they were designed for. You could have the music player in one HTML frame and the rest of the page in another so when you move around you are only updating the main content frame.
Or do as gurav suggests and make your whole site one page and update the content with Ajax, so the music Div does not change.
Pass the current position of the player to the next page when you click a link.
to another page
Where getseconds() returns the current position of the music player and passes it to the next page then when that page is loaded you read in the variable from the URL and start the player from there.
Using frames is one solution but since you are using JQuery on your site you should check out .load (http://api.jquery.com/load/). It allows you to load the content of another page and put it somewhere in the current page. Something like this:
$(function () {
$("a").click(function (e) {
e.preventDefault(); // don't follow the link
$("#ja-container").load($(this).attr("href") + " #ja-container");
/* Load the new page using ajax request, take the content in #ja-container from that new page and put it in the current page's #ja-container */
});
});
This is not a complete solution: when someone clicks Concerts -> Agenda you should keep Agenda visible.
Personally, instead of forced background music I'd rather like to see a page with Youtube videos of the people playing the music.
Well, yes HTTP is stateless. what you can do is create a cookie, and update it with current location/time value of the player, constantly. This way, when you go to any other page you can read time/location from cookie.
otherwise, in a cookie less approach, sending AJAXed location/time data back-forth server-client will be too much network.
If I was doing this, I would have gone cookie way.

Prevent open in new tab/window

I have a website that has a music player in one of the corners. Because I didn't want the music to stop everytime the user changes part of the website, I used an iFrame for the content. So when someone clicks the menu buttons, all that changes is the source of the iFrame.
Now the only problem is if someone tries to open one of the sub-pages in a new tab/window. All they get is black text on a white background, with the content that was supposed to be in the iFrame.
Is there any way to prevent this?
Oh, and the page this is about is www.sinjabe.com if that helps.
Thanks
The most logical solution (to me...) would be to detach the music player from the page; have the music player open in a different window / tab. You can have the music player in a pop-up window when the visitor of your site requests it / clicks on it.
Other solutions like detecting if the content has a parent frame, will lead to multiple music players if someone opens a page in a new tab / window.
You can alter your sub-pages to detect if they are loaded in an iframe like this:
(window.location != window.parent.location) ? true : false;
and then load or redirect to the full template as needed.
Put this on your sub pages:
<script type="text/javascript">
if (window.location == window.parent.location)
this.window.location = 'main_site.html';
</script>
-- Give credit for this one #George Cummins for writting such a short conditional statment :)
This will redirect any direct incomming trafic on your subpages to your main page. I must warn you though, that iframes for displaying such content are highly SEO unefficient, and URL useless in terms of history mapping (back button will not work) and link sharing, because the main URL doesn't change while you click on menu buttons.