jQsafi / jscrollpane

Automatically exported from code.google.com/p/jscrollpane
0 stars 0 forks source link

jscrollpane overrides all document BODY if scrollable text has document.write() #254

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To demonstrate the problem I have attached the test file jscrollpane-pure.html. 
It contains a confirm() call to demonstrate, that the javascript contents is 
performed twice and how page contents depends on 2nd document.write call.

What steps will reproduce the problem?
1. open jscrollpane-pure.html in your browser
2. when it asks "write?" click yes: the content will be rendered
3. whet it asks "write?" again, click yes: the page will become blank

What is the expected output? 
Ideally, the second time the "write?" should not appear, but even if it 
appears, after clicking it the page should remain unchanged, i.e. title should 
not disappear and the text "hello" should be there.

What do you see instead?

The page becomes blank after the second "yes"

What version of the jScrollPane are you using? On what browser? And operating 
system?

The links to jScrollPane are taken from current example, for my tests I used 
Google Chrome 14 and FF6 under ArchLinux

Original issue reported on code.google.com by kurgu...@gmail.com on 13 Oct 2011 at 5:35

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

This isn't the correct place to report issues for jScrollPane any more. You 
should use the Github issues list as mentioned on the jScrollPane homepage. 
Also, an example that I can see and interact with (e.g. hosted or on 
jsfiddle.net ) is more useful than an attachment.

Those points aside, from a quick look at your example I would say that it is 
not recommended to use document.write after a page load and doing so will have 
all sorts of undesirable effects. Why not use something like 
$('SELECTOR').html('What you want to write')?

Original comment by kelvin.l...@gmail.com on 13 Oct 2011 at 8:04

GoogleCodeExporter commented 9 years ago
> This isn't the correct place to report issues for jScrollPane any more. You 
should use the Github issues list as mentioned on the jScrollPane homepage. 

Thank you for clarification, please let me know, if I need to resubmit the 
issue to Github.

> Those points aside, from a quick look at your example I would say that it is 
not recommended to use document.write after a page load and doing so will have 
all sorts of undesirable effects. Why not use something like 
$('SELECTOR').html('What you want to write')?

Our product (ecwid.com) is actually a javascript widget, that does not depend 
on jquery and must build it's DOM tree dynamically after a page is loaded. Our 
code is more complex, than just document.write(...), so I created that simple 
html-file to outline the key point of conflict between our widget and 
jscrollpane.

Please, let me know, if more info is required.

Original comment by kurgu...@gmail.com on 13 Oct 2011 at 10:31

GoogleCodeExporter commented 9 years ago
I would still recommend against using document.write. It will have unexpected 
results on a whole variety of pages. You should be appending your new elements 
to the document instead using the DOM.

Here is an example of how you could do that:
http://www.sitepoint.com/insert-in-place-without-documentwrite/

Original comment by kelvin.l...@gmail.com on 13 Oct 2011 at 10:42

GoogleCodeExporter commented 9 years ago
Thank you for your reply. Unforutnately, this approach is based on already 
having a unique id, to which the new DOM element can be added. In our case the 
element must be added into that very place, where we called our function, 
without knowing id of it's surrounding element (if it has id at all).

My concern is to provide you with necessary and sufficient information about 
the problem, so feel free to ask, if I missed something in my description.

Original comment by kurgu...@gmail.com on 13 Oct 2011 at 11:01