Page only loads CSS and JavaScript after refresh [closed] - javascript

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 8 years ago.
Improve this question
The first time I load the page it's a mess and JavaScript functions don't work. The second time it looks ok and works.
Any brief idea what might be causing this behaviour? I'm using Backbone.js and jQUery Mobile if that makes a difference.
Sorry for no code, but I need to go to a meeting in a moment and the website is huge so I don't really know what part to show you.
If anybody knows why this is happening and doesn't need to see the code, please help.
UPDATE:
Here's what seems to be the answer: https://forum.jquery.com/topic/script-not-running-unless-i-refresh-page
Thank you for suggestions, I upvoted the ones that seem relevant.

It sounds like unmet dependencies: some of your functions probably run before the document is fully loaded and can't get their job done correctly (missing elements, etc..). The second time the function work beacuse the page is cached and so loaed in time before the function starts.
I'd start looking at the JavaScript console and post the errors here if you can't figure it out alone, but without proper informations what we could do is just poor absumptions.

Might be javascript source could not be fetched from the url given. You can do inspect element and see what's happening on console or network tab.

Related

Similar and simplified examples (newbie questions) [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 4 years ago.
Improve this question
I'm currently studying about web development, I still don't know about jquery, but I've a little knowledge about javascript, html and css (basic).
I've been looking at some examples in github to improve my skills, and I've found this content;
https://github.com/stewilondanga/editables
I perfectly understand the theory, but I do not know how to put it into practice, I would like for any similar examples (simplified alternatives) and how to convert the exported code generated by javascript into a html5 table?
Any example would be appreciated! thanks for your attention!
First of all, jQuery does not generate code. It's a framework, you load it into a web page, and then you can use it from within Javascript code in that page.
I suggest you start by looking at the source of https://stewilondanga.github.io/editables/, if an editable tables is what you need. There are more general frameworks to do this, e.g. Aloha
To try it yourself, I'd suggest you bite the bullet equip yourself with some kind of web server, be it on a server somewhere, or on your local machine, so you can easily try out things like this, copy the sources, alter the code etc.., and quickly hit reload on your browser.
While it may seem easier to run a local server and point your browser at http://localhost/something, IMHO it also takes more tinkering to get browsers to embrace that fully. You don't need the extra grief while already learning all those new concepts. If you want to tackle this seriously, consider getting a hosting service or small VPS somewhere. If you don't know how to do that, get help for that first, but get it out of the way. It'll save you much grief.

Why does alert return this way in Chrome? [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 6 years ago.
Improve this question
Folks! I'm wondering where to start to understand why JavaScript alert returns in Chrome in this way. Can it be lacking JavaScript in PHP source code? .Where should I start to understand and diagnose the problem?
My Script
"<script type='text/javascript'>
$(document).ready(function(){
$('#menu2').click(function(event){
event.preventDefault();
alert('Text');
})
});
</script>";
Result Chrome:
Result Mozilla
The reason the default pop ups in chrome don't look good is because they aren't really important, so there's no reason for the developers at Google to spend a bunch of time designing and building beautiful ones. If you look at the pop ups in most other browsers (to the best of my knowledge), they will look similar.
Your second screenshot looks like some sort of modified version (possibly bootstrap?) and has absolutely nothing to do with the default pop up.
So to answer your question, no, there is no missing javascript or PHP source code. It's just a design choice on the part of Google to focus resources into more important areas.
If you want to change the look, you can't. It's part of the browser, not part of the website. But, if you really need to have a better looking one (and I would strongly recommend you look into different options as pop ups are bad UX), http://jqueryui.com/dialog/ will be able to help.

Which way is better to call a jquery function twice? [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 years ago.
Improve this question
I have a javascript jquery function which I need to use twice, in 2 different files.
Now, the question is, which is the better way to implement it, performance-wise. Should I declare function global using 'window' variable, or should I declare the function in each of the files?
Please keep in mind that traffic is not an issue, the script will be used from the hard-drive.
Thanks for your help.
My answer follows the DRY Principle (Don't Repeat Yourself). If you put the function in both files, and later find a bug on Page #1, someone has to remember that the function is duplicated on Page #2 as well (in this case, assume the bug report says "Page #1 doesn't work properly"). From that bug report, would the developer know to also modify Page #2? To avoid the human error piece, I'd always recommend you don't copy/paste functions into multiple locations.
Performance wise, if you're not concerned about traffic, the difference is nanoseconds slower wrapping it in a shared function as you do have to create an additional stack frame for the shared function call that in turn calls jQuery, but we're really talking nanoseconds. For a few nanoseconds lost, I'd say DRY is the way to go.

Mysql database made scolling get stuck [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
I'm building a website and started with this scrolling system, then I added a mysql database but when I get to the pages where he has to scroll it jams. I inspected the element an I can see there are errors but I don't know how to fix them, im very desperate and hopefully someone knows how to fix this problem. The page where the scrolling jammed is: http://catalogusdertoeval.nl/woord.php?id=351 at least that is one of the pages but it is all the same problem on the other pages.
Hopefully this should guide you a bit. I did two things but you'll have to figure the rest it.
1. Checked out the errors that are created:
2. Then I did a quick google search since I don't use jQuery that often.
I'm thinking the browser stopped executing your javascript because of errors in your code. I don't MySQL has anything to do with it.
Note:
I did not go through your code.

Javascript inconsistent behavior when website is deployed [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 8 years ago.
Improve this question
We have an ASP.NET MVC website and the problem we have is this:
When the website is deployed, we see some strange Javascript related bugs, that never occur when running the website locally (on any of our computers).
For example:
An accordion menu opens and closes itself immediately when clicked, instead of just remaining open normally.
Some links that have their click event handled by Javascript suddenly ignore the event handlers, and just do nothing when clicked.
We have checked the files on our integration machine, and checked the build process many times, and we deploy the correct version of the files each time.
Where else could we check to fix this issue?
Any and all suggestions are welcome !
Thanks.
Thanks everyone !
We use Cassette for bundling our scripts, and as it turns out, I didn't notice that when we deploy, the cassette obtains one the the javascript files using a url.
That url pointed to a script we no longer use, and that was the cause for all of the weird bugs.
Thanks again.

Categories

Resources