This is one of these situations where I could read the jQuery API and find out for myself how cloning works, but I find it more satisfying to ask here on this forum and get a good answer from you guys :-)
It seems that there are seven undocumented jQuery methods:
init()
pushStack()
push()
sort()
splice()
extend()
domManip()
I am not talking about members of the jQuery object as in $.member, but about members of the object returned by the jQuery factory function as in $("div").member.
I don't have the motivation to figure out how exactly these methods work, but a quick Google search didn't return much info...
I'd be happy to find out more about these methods...
The support for unload() in Firefox, Chrome and Safari is almost 100%.
Opera doesn't seem to like scripts being executed on unload at all...
The main issue here is that unlaod() is badly supported in IE8.
Only reloading the page and closing the browser window causes unload() to execute. The other reasons (which are far more important) - using the address-bar, using the back/forward buttons, clicking on links - do not cause unload() to execute.
But the function referenced by onbeforeunload gets executed in all those cases!
This means that, all the jQuery developers had to do is, for IE browsers, bind the unload() callback function to onbeforeunlaod, but for some reason they did not do that.
I know this can be done in JS, but I'm not particularly experienced in JS string manipulation, so it would take a while until I would accomplish this...
I was irritated how Firefox and Chrome fire the resize event multiple times while the user resizes the browser window, so I wrote a little script to deal with that...
The issues...
Firefox = if you resize the browser window using the "resize area" at the bottom right corner of the window, then the resize event will be fired every ~20ms for as long as you drag the corner of the window.
Chrome = if you resize the browser window, the resize event will be fired twice !!
Since I want to run some complex code on window.resize, I can't afford to run it multiple times during one single resizing, so I wrote this JS snippet to deal with that.
It is located here:
(URL removed; I don't have the demo online anymore)
Is is not a custom jQuery event, it's just a setTimeout that runs the code only after all resizing is done...
I WOULD LOVE TO SEE THIS IMPLEMENTED IN JQUERY!! (or at least in a plug-in)
So that you can write this...
$(window).resizeend(function() {
// run this code only once after the user finished resizing
This is completely off topic, but I really would like to hear your opinions on this!
So, I wanted to test the XML parsers in modern browsers (FF, Chrome, Safari and Opera).
I configured my local server (IIS) to serve .html files under this MIME type: "application/xhtml+xml".
Next, I made a simple XHTML page containing only one paragraph. I placed this file in one of my web-apps that are hosted by my local server, and requested the file with Firefox.
The page loaded successfully and I used the Web Developer Toolbar to view the response headers, and as I expected, this header was serverd:
Content-type: application/xhtml+xml
Next thing, I wanted to see what happens if the XHTML file is not well-formed, so I deleted the closing tag of the paragraph ( I deleted "</p>" ). Guess what happened?
I tried to load the page in Firefox, and it was not displayed at all. Firefox informed me that there was a XML parsing error, as I expected. But no content at all was displayed!
So, let's say that in the future complex web-applications are going to be served with the xhtml MIME type, ergo, they are going to be parsed with the XML parser in the browser. Then, if the author of the application makes one tiny little error (for example, he forgets to close an element, or he forgets to use apostrophes on one of the attributes), then the whole web-page won't be displayed.
Is it just me, or is this idea ridiculously stupid?
Also, if Internet Explorer does not have a XML parser, then why are so many pages using the XHTML doctype (even this very forum)? Even, if IE9 does come with a XML parser, it will take years for IE8 to be flushed of the market.
I have an ASP.NET web-app that consists of a master page and several .aspx pages that use that master page.
1. problem:
If I include the jQuery library in the master page at the bottom right before </body> (and after the content placeholder), then in my .aspx pages I am unable to use jQuery because it is included "below" all JS code defined in the pages.
Master page:
<!DOCTYPE html>
<html>
<head>
...
< ASP.NET head placeholder >
...
</head>
<body>
...
< ASP.NET body placeholder >
...
<script src="jquery.js"></script>
</body>
</html>
Regular .aspx page that uses the master page:
< head placeholder > ... </head placeholder>
<body placeholder>
... code for that particular page ...
<script>
... JS code for that particular page ...
</script>
</ body placeholder >
The only solution for this problem (that I can think of), is to include the jQuery library in the HEAD of the master page...
2. problem:
At first I was placing the document.ready() code for each .aspx page at the bottom of the page = inline.
Like this...
<script>
$(document).ready(function()
...
});
</script>
However, I thought maybe it's better to place all JS code into one or more external files, so that JS is independent of HTML. So I can:
a) define one JS file for each .aspx page (which seems kind of stupid)
b) put all the code into one file - but then all code runs for every .aspx page that is executed. So if I have, for example, Map.aspx for wich the document.ready() function manipulates a map, and Calendar.aspx for which the document.ready() function manipulates a calendar, if I place all this code into one external document.ready() function, then all this code will run for both the Map.aspx and Calendar.aspx pages.