Website behavior different when reload [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm facing the following problem, when I refresh my webpage her behavior is just as expected but when I use reload (just press enter on url input) her behavior becomes weird. When the page is loaded I'm calling a $(document).ready function and inside of it I'm getting an element height. Well in the first case (refresh) the height of the element is just fine, but in the second case (reload) this height is smaller, which causes the problem I'm talking about.
Why is this happen? And how can I prevent this without forcing the webpage to refresh?
Thanks

This sounds like your browser is caching on reload but when you hit enter on the url it's not loading the site form cache. This is why your page isn't getting the height of the div properly.
I had this problem before and I solved it with this:
$(function() {
setTimeout(function()
// get the height of elements here
}, 250);
});
Needless to say this solution isn't ideal. If you can try and set the height in css.

Related

Message for Browser Tab [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
I want to add a message for example: If the user leaves the browser tab, the message "Looks like you're gone ..." should appear. When the user returns to the page, change the message to "Good to be back".
Is it possible to do something like this?
Crate an eventListener on your window, with the load event, and simply show an alert.
And create an event on your window called onbeforeunload (more info about the event), where you show an alert while leaving the page.
Note: onbeforeunload won't work in this snippet, but try putting inside your code.
window.addEventListener('load', (event) =>{
alert("Looks like you are back");
});
window.onbeforeunload = function() {
alert("Looks like you want to leave");
};
You can achieve this with the Page Visibility API
Answered here

Is there a way to hide the fact that you minimize the browser or unfocus from some window [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
So I was wondering if there is a way to hide you're activity from a webpage that uses JavaScript (And libraries such as AjaX or JQuery).
By activity I mean that I don't what the webpage to know that I'm switching tabs or minimizing the browser, unfocusing and etc.
I know you can track someones activity like so:
$(window).focus(function() {
console.log("YOU'RE BACK")
});
$(window).blur(function() {
console.log("YOU'RE OUT")
});
And I can stop it by writing the following in the console:
$(window).off()
But I'm sure there are million other ways to do so, and I want to make sure that any specific webpage doesn't do so.
So, How can I make sure that no sensitive information leaked?
also note that I don't want to block JavaScript completely, because I want the webpage to still work.

ASP.NET change text with no page refresh on button click [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've found a couple other threads containing the same questions, but none of them had an understandable answer. I am supposed to make client side changes, but that is only possible in the .ascx file and if for instance i want to call a function to calculate something and then display it with no page refresh that is not possible :( any easy solutions?
With jquery, you can replace the contents of any existing HTML element using the .html() function. For example,
$("#MyDiv").html("Here is the new text.");
Since the function takes HTML as an input, you can even set the style if you want:
$("#MyDiv").html("Here is some text. <DIV class='foo'>Here is some more text in a different style.</DIV>");
You can also add new elements using .append(), like this:
$("#MyDiv").append("<p>Even more text</p>");
To do this upon a button click, you would use the .click() function. So your code would look something like this:
$("#MyButton").click(function() {
$("#MyDiv").html("You just clicked a button!");
});

URL/address bar code to hide a specific div on the webpage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
It is possible to put some code on a link that when somebody press on the link to send a command to the browser in order to hide a specific div in the link target webpage? Thank you.
if your goal is to have a div hide when the user clicks a link, there's no need to reload the whole page with some fancy querystring. Just call a javascript function when the link is clicked:
<div id='hide-me'>This is the div you want to hide</div>
<a href='#' onclick='hideTheDiv()'>hide something</a>
<script type='text/javascript'>
function hideTheDiv() {
$('#hide-me').hide();
}
</script>
For your info, the href='#' tells HTML not to reload the page or go anywhere. so the page stays where it is. onclick tells HTML to run a javascript function.
Sounds like you've got some learning to do. checkout these resources:
http://www.w3schools.com/jsref/event_onclick.asp (can be applied to an anchor tag too, not just buttons)
http://www.w3schools.com/jquery/jquery_ref_selectors.asp

Replacing document with jquery [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
so what I'm trying to do is simple to explain: I have one page (let's call it login.html) that has a script whenever an $.get $.load $.post is called it shows an progress bar like youtube now my problem is to move to another page with one of this methods so for example I complete the login and it loads the page2.html and only shows the page2.html and leaves login.html after page2.html is ready to be displayed
Kind of like a preload, any ideas? I've tried the $('hmtl').load('page2.html'); but it messes up my CSS and SCRIPTS
You can try to use ajax loader which basically preloads the specified page and then just switches a body element of current and the preloaded page.
Here is an example

Categories

Resources