I want to redirect a IE7 user, but window.location.href does not seen to work properly.
Any suggestion?
$('.navigation-next a').bind('click', function (a) {
a.preventDefault();
window.location.href = $(this).attr('href')
})
Worked with:
$('.navigation-next a').bind('click', function(a) {
location.href = $(this).attr('href')
})
Thanks!
You have to use window.location.replace() on IE7 and earlier.
<script type="text/javascript">
function redir(url){ window.location=url; }
</script>
<!--[if lte IE 7]>
<script type="text/javascript">
function redir(url){ window.location.replace(url); }
</script>
<![endif]-->
This is why all web developers should drop support for IE until Microsoft fixes it!
Related
<!--[if lte IE 9]><html class="lte9"><![endif]--><!--[if gt IE 9]><html><![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
blah blah
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="{{ asset('js/mypage.js') }}" type="text/javascript"></script>
</body>
</html>
when I load my page, IE9 brings error like this '$' is not defined.
How can I solve this error?
+++ mypage.js
$(function(){
//when load page,
//ie9 i tag not moving.
$(window).load(function() {
$('div.mask').hide();
});
// when click about , willshow will show.
//for not IE 9
if (!$('html').hasClass('lte9')) {
var about = $('ul.about > li > span.activebtn');
var willshow = $('div.willshow');
about.on('click',function(){
willshow.toggleClass('active');
about.html(function(){
if ($(willshow).hasClass('active')) {
return 'close';
}
return 'about';
});
});
}
// because CSS3 not working in IE9.
if($('html').hasClass('lte9')) {
about.click(function(){
willshow.animate({
'left': '0'
}, 500);
about.html(function(){
if (willshow.hasClass('active')) {
return 'close';
about.click(function(){
willshow.animate({
'left': '-100%'
}, 500);
});
}
return 'about';
});
});
}
});
check my js file plz. beacause IE9 not support css3, I just want to make animate function in place of CSS3. It work successfully in chrome.
I have linked to jQuery like so <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> and included the following script:
$(document).ready(function(){
$('.myLinkToTop').click(function () {
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
return false;
});
$('.myMenuLink').click(function () {
$('html, body').animate({scrollTop:0}, 'slow');
return false;
});
})
But the script will only work in Firefox, and not Opera, Chrome or Safari. Is there anything I'm missing out?
Trying to learn JQuery here, im starting off really simple.
When I click the button, the page reloads and nothing happens.
Heres my JS:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$("#submitShout").click(function() {
alert('hi');
});
</script>
Here's my html:
<div class="panel right">
<form name="shout" >
<textarea name="text" id="text" class="ribbitText"></textarea>
<input type="submit" id="submitShout" value="Ribbit!">
</form>
</div>
i think you forgot document.ready..
$(function () { //<--- here..the codes below is called whn document is ready
$("#submitShout").click(function () {
alert('hi');
});
});
Make sure you include jQuery reference and you code surrounded with
$(function(){
});
as
$(function () {
$("#submitShout").click(function () {
alert('hi');
});
});
or click binded at the end of the document
Just try this,
$("#submitShout").on("click", function() {
alert('hi');
});
If it is lower version Jquery, try this.
$("#submitShout").live("click", function() {
alert('hi');
});
jQuery 1.9 version
$(function(){
$("#submitShout").on('click',function(){
//your code
});
});
jQuery version lower than 1.9
$(function(){
$("#submitShout").live('click',function(){
//your code
});
});
that's a really old jquery version, upgrade it to something newer:
https://developers.google.com/speed/libraries/devguide#jquery
I guess Either you are missing the doc ready handler or the jQuery lib:
first try with this:
$(function(){
$("#submitShout").click(function() {
alert('hi');
});
});
then this one:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$("#submitShout").click(function() {
alert('hi');
});
});
</script>
make sure jQuery is loaded
use the latest jQuery library
check the error console (using chrome developer tools or firebug for firefox
try changing your jQuery to
code:
$(function(){
$("#submitShout").click(function(e) {
e.preventDefault();
alert('hi');
return false;
});
});
Try this
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#submitShout").click(function(event) {
alert('hi');
event.preventDefault();
});
});
</script>
I'm relatively new to JQuery and would like to try something. I just followed a simple tutorial to start up with on http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
So I specified my script in the :
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
alert("Hello world!");
});
});
</script>
and included a test link in the :
Link
however, when I refresh thet document my browser keeps saying
TypeError: Property '$' of object [object Window] is not a function
which I can understand for "normal" JavaScript but I believe this kind of function is new in JQuery. Can someone assist mer here, please?
links:http://wittmerperformance.com/site/
Did you embed the jquery library?
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
Further more I think that currently "on" is state-of-the-art as in:
$(document).ready(function() {
$("a").on('click', function() {
alert("Hello world!");
});
});
try this:
jQuery(document).ready(function($) {
$("a").click(function() {
alert("Hello world!");
});
});
The reason for the issue that you are facing could be that you haven't included JQuery library or it may be due to conflict, give it a try using
jQuery(document).ready(function ($) {
$("a").on('click', function() {
alert("Hello world!");
});
});
<script type="text/javascript">
$(document).ready(
function() {
$("a").click(
function(){
alert("Hello world!");
});
});
</script>
this is a working example.simpler. in your example you fotgot to close a function you started. count ( { } ) ; you are missing }) at the end. it shold work fine yours too.
full working example below:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
$("a").click(
function(abc){
alert("Hello world!");
abc.preventDefault();
return false;
});
});
</script>
</head>
<body>
<a>some link</a>
</body>
</html>
I have the below code in a HTML page on my site. The url parameter is loading fine on a pixel fire right above it but for some reason the redirect doesn't want to fire. Anyone have any ideas? It might be an IE issue but not sure.
<script type="text/javascript">
$(document).ready(function() {
setInterval("window.location = '{{$url}}'", 4000);
});
</script>
<script type="text/javascript">
var url = '...';
$(document).ready(function() {
setInterval(function() {
window.location.href = url;
}, 4000);
});
</script>