Mozilla Firefox bug or ..? [closed] - javascript

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I wrote the code and saw a bug in firefox and little bug in chrome
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mozila Firefox</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
alert('1');
}
});
});
</script>
</head>
<body>
CONTENT FOR SCROLL
</body>
</html>
When I scroll this page in firefox i getting bug which covers the black transparent background browser.
In chrome just more and more alerts.
Close your tabs in firefox!
Live: http://forum.xeksec.com/habr/mozilla_crash_or_wtf/

See https://bugzilla.mozilla.org/show_bug.cgi?id=723532

Edit :
The above doesn't always work... In fact, I've checked some solutions around, including here in Stack Overflow. What other usually advice have the same problem (eg Alert using Jquery when Scroll to end of Page)
I'm using FF11 on Ubuntu.
I think this was a performance issue. If you put your maxScroll in a variable it works (at least for me)
Here's my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mozila Firefox</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
var maxScroll = $(document).height() - $(window).height();
$(window).scroll(function(){
if ($(window).scrollTop() == maxScroll){
alert('1');
}
});
});
</script>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>

Related

select all text in JavaScript [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 need to select all text in my html code and surround them with <span> tag in JavaScript
convert this code:
<!DOCTYPE html>
<html>
<body>
<h1>Heading</h1>
<p>paragraph.</p>
</body>
</html>
to this:
<!DOCTYPE html>
<html>
<body>
<h1><span id="text">Heading</span></h1>
<p><span id="text">paragraph.</span></p>
</body>
</html>
how can i do this?
You can wrap your text with this fonction :
$(selector).wrapInner( "<span class=\"text\"></div>");
where selector target the tag you want
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(e) {
$('html').prependTo('<script>');
});
</script>
</head>
<body>
hi
</body>
</html>

Jquery based WYSIWYG with On-Air possibility

I have come across http://redactorjs.com which is a very nice wysiwig editor that has on air ability. In other words, in one single line you can turn a static div into an editable text area on the fly.
I -do not- want to pay for it (for some reasons I won't disclose) hence I am looking for an alternative.
Have you ever used a lightweight wysiwig jquery based editor that is easily usable on the fly?
I am looking for something I would use as follow:
$("#edit_btn").click(function({
$("#my_div").turnIntoEditor();
}));
$("#save_btn").click(function({
$("#my_div").post_content("http://target");
$("#my_div").turnIntoStatic();
}));
Please do not mind the post_content thingy and other function names as they are just given for reference to show the kind of usage I am looking after.
Thank you
I finally went for ckeditor. I could use it easily as follow (poc):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<title>Title</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#edit").click(function(){
$( '.editable' ).ckeditor();
});
$("#save").click(function(){
var editor = CKEDITOR.instances['editor'];
if (editor) { editor.destroy(); }
alert($('#editor').html());
});
});
</script>
</head>
<body>
<span id="edit">EDIT</span> <span id="save">SAVE</span><br/><br/>
<div class="editable" id="editor">
Some useless content
</div>
</body>
</html>

how to pick value in 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
i have build a small function whose work to get value in alert box but i want to pick only 5 character from starting. here is my function
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function (){
$(".hhh").click(function(){
$(this).html()
})
})
</script>
</head>
<body>
<div class="hhh">dd:ff:aa</div>
</body>
</html>
You could use the substring method:
$('.hhh').click(function() {
alert($(this).html().substring(0, 5));
});
Obviously checking the length of the string before calling substring to ensure that it has at least 5 characters could be a good check to do.
Do you mean substr ?
$(this).html().substr(0, 5);

Writing Image Gallery (Javascript) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I just want to ask if anyone could help me write that image gallery?
Screenshot how it should look like: link
This is what i come up with:
jsgalerija.html
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JS Galerija</title>
<link rel="stylesheet" type="text/css" href="jsGalerija.css" />
<script type="text/javascript" src="jsGalerija.js"></script>
</head>
<body onLoad="galerija();">
<table class="galerija">
<tr><th>Seznam</th><th>Slika</th></tr>
<tr>
<td id="seznam"></td>
<td id="slika">Klikni na sliko v seznamu!</td>
</tr>
</table>
</body>
</html>
jsGalerija.js
function galerija()
{
images = new Array();
images[0]="slike/image1.jpg"
images[1]="slike/image2.jpg"
images[2]="slike/image3.jpg"
images[3]="slike/image4.jpg"
for(i=0; i<=3; i++)
{
document.getElementById('seznam').innerHTML = '<IMG SRC="' +images[i]+ '"><br />';
document.getElementById('slika').innerHTML = '<IMG SRC="' +images[i]+ '"><br />';
}
}
If anyone can help me, I would really appreciate it. Thanks in advance.
As stupid as this answer may seem, you can use a code snippet from a site like Dynamic Drive:
http://www.dynamicdrive.com/dynamicindex4/indexb.html

How can I detect browser support of Flash in JavaScript? [duplicate]

This question already has answers here:
Closed 11 years ago.
This my HTML code but if the browser does not support Flash then I want to replace the image in the Flash part
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
if (typeof navigator.plugins['Shockwave Flash'] !== 'undefined') {
alert('support');
} else {
alert('not support');
}
</script>
</head>
<body>
</body>
</html>
I would use one of the Flash Detection JavaScript libraries out there. This one works well.

Categories