Click here to Skip to main content
       

JavaScript

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionHTML issue with IE. PinmemberInderK16hrs 29mins ago 
Hi,
 
Below code is not working in IE-8 but it is working good in all other browsers. I am not able to understand what is wrong in this code as it is very simple one.
 
<a href="abc.htm" target="_blank;">Click here</a>
When I click on a link nothing happen. Please let me know how to fix this for IE.
 
Thanks in advance,
Inder...
AnswerRe: HTML issue with IE. PinprofessionalRichard Deeming15hrs ago 
Questionjquery/jquerymobile - image inside collapsible>listview [modified] PinmemberPrasoon Chaudhary13-Jun-13 6:57 
I am trying to create a dynamic collapsible-set which would contain text and image. Texts are appearing fine but as soon as I try to write code (see commented line) for image, browser doesn't display it correctly. It takes 2-3 clicks to open the collapsible, and it gets stuck most of the time. Here is my code:
<pre lang="Javascript">
$("#dvAccordion").empty();
var outdiv = $('<div data-role="collapsible-set"></div>');
$(strXML).find('Category').each(function(){
    var colldiv = $('<div data-role="collapsible" data-collapsed="true"></div>');
    colldiv.append('<h3>' + $(this).find('Category_Name').text() + '</h3>');    
    var uldiv = $('<ul data-role="listview" data-inset="false"></ul>');
    colldiv.append(uldiv);
    //
    $(this).find('Menu_Item').each(function(){          
        var sItemName = $(this).find('item_name').text() ;
        //var sImageUrl = $(this).find('item_image').text() ;
        var sImageUrl = "images/food1.jpg" ;
        uldiv.append('<li><a href="menu.html" rel="external">' + sItemName + '</li>');
        //uldiv.append('<li><a href="menu.html" rel="external"><img width="50" height="50" src="' + sImageUrl + '" />' + sItemName + '</a></li>');  
    });
    //
    outdiv.append(colldiv);
    outdiv.appendTo('#dvAccordion');
});
//$('#dvAccordion [data-role=collapsible-set]').collapsibleset();
//$('#dvAccordion').collapsibleset('');
//$('#dvAccordion').collapsibleset('refresh');
$('#dvAccordion').trigger('create');
 
Where am I wrong? If I try to generate the collapsible with listview and images static way in html - everything works fine.
 
jsFiddle - http://jsfiddle.net/yesprasoon/68v8p/
Surprisingly, images are appearing properly in fiddle. But it doesn't appear in my local file/ localhost address/ phonegap application. Frown | :-(

modified 2 days ago.

QuestionjQuery - getting selected item of dynamic listview [modified] PinmemberPrasoon Chaudhary13-Jun-13 6:13 
I am generating a dynamic collapsible-set with listViews using XML data. It's generated correctly, but I need a click/touch event to display some data before it goes to another page. Here is my code:
$("#dvAccordion").empty();
var outdiv = $('<div data-role="collapsible-set"></div>');
$(strXML).find('Category').each(function(){
    var colldiv = $('<div data-role="collapsible" data-collapsed="true"></div>');
    colldiv.append('<h3>' + $(this).find('Category_Name').text() + '</h3>');    
    var uldiv = $('<ul  data-role="listview" data-inset="false"></ul>');
    colldiv.append(uldiv);
    //
    $(this).find('Menu_Item').each(function(){
        var sItemName = $(this).find('item_name').text() ;
        uldiv.append('<li data-name="baby"><a href="menu.html" rel="external">' + sItemName + '</a></li>');                         
    });
    //
    //$('#dvAccordion').listview('refresh');
    //
    outdiv.append(colldiv);
    outdiv.appendTo('#dvAccordion');
});
//$('#dvAccordion [data-role=collapsible-set]').collapsibleset();
//$('#dvAccordion').collapsibleset();
//$('#dvAccordion').collapsibleset('refresh');

$('#dvAccordion').trigger('create');
I am adding an eventListener on page load like this:
$('#dvAccordion ul').children('li').bind('vclick', function(e) {
alert('Selected Name=' + $(this).attr('data-name'));
});
 
Where am I wrong? If I try to write the same event listner after developing collapsible in static way in html - everything works fine.
 
jsfiddle - http://jsfiddle.net/yesprasoon/MvcHm/

modified 2 days ago.

QuestionMessage Automatically Removed Pinmemberramneekchauhan12-Jun-13 1:06 
Message Automatically Removed
AnswerRe: Free java online course Pinmemberdusty_dex12-Jun-13 2:15 
GeneralRe: Free java online course PinmvpRichard MacCutchan12-Jun-13 2:30 
GeneralRe: Free java online course Pinmemberdusty_dex12-Jun-13 7:02 
QuestionPassing objects byref between html windows Pinmembertiwal11-Jun-13 23:30 
I am developing a small html/js application where one window calls another , just to keep functionalities separated .
I need to reference , in the child window (opened with window.open (url....) etc) , an object, lets call it obj, defined in the opener.
I can correctly see, in the child window, all the methods, and all the properties with the values corresponding to the ones set in the opener. But when it comes to modify them, it looks like I am modifying a copy of the object : I send an alert in the child window to verify I correctly changed the value of the properties, but when debugging the parent (opener) window, it seems like those changes didn't happen at all, that is I see the old values.
I reference the parent's object, in the child window, as : self.opener.obj. I thought this represented a reference to the parent's object, but what's happening lets me think this is just a reference to a copy of that object, not the object itself.
Is it correct ?
QuestionCalling a function from within a function question [modified] PinmemberCalufrax1211-Jun-13 14:06 
Hello. I am attempting to create a small app that rotates images, with buttons to stop, slow or speed up the animation, or to start/reset.
 
The button functions work, but when they try to contact another function (setSpeed) or even use setTimeout or setInterval, those are ignored. Putting in other commands in those functions (e.g. window.alert("test") statements yields results, so I know it's doing something.
 
Any help would be much appreciated...
 

 
<!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>
<title>Animation</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
	<!-- // hide from older browsers
	
	
	/* <![CDATA[ */
	
	var myFx;
	currImage = "pennant2.gif"; // document.getElementById("dhtmlFx").src;
	xName = "dhtmlFx";
	speedVar = 500;
	speedVal = 100;
	maxVal = 1500;
	stopSpeed = 99999;
	var startFlag;
	startFlag = 1;
	y = speedVar;
	//var filename = fullPath.replace(/^.*[\\\/]/, 'currImageObj.src')
		//window.alert(filename);
			
			
	function startMe()
	{
		startFlag = 1;
		myFx = setInterval(doFx, speedVar);
	}
	function doFx()
	{
		currImageObj = document.getElementById(xName);
		myText = document.getElementById("dhtmlText");
		myText.textContent = y;
				
	    if (currImage == "pennant2.gif") { 
		currImageObj.src = "pennant1.gif";
		currImage = "pennant1.gif";
			} else { 
		currImageObj.src = "pennant2.gif";
		currImage = "pennant2.gif";
		}
				
	}
	
	
	function startThis()
	{
		if (startFlag == 0)
		{
		y=speedVar;
		startFlag = 1;
		setSpeed(y);
		} else {
			window.alert(startFlag + " Animation already started");	
		}
	}
 
	function slower()
	{
		y+=speedVal;
		if (y>= maxVal )
		{
			y=maxVal;
		}
	
		startFlag = 1;
		setSpeed(y);	
	}
	
	function faster()
	{
		startFlag = 1;
	
		y-=speedVal;
		if (y<= 0 )
		{
			y=1;	
		}
		
		if (y > maxVal)
		{
			y = maxVal;	
		}
				
		setSpeed(y);
	}
	
	function stopThis()
	{
		startFlag = 0;
		y = stopSpeed;
		clearInterval(myFx);
	}
	
 
	function setSpeed(y)
	{
		clearInterval(myFx);
		var myFx = setInterval(doFx,y);
	}
	
	/* ]]>*/
		
	// end remark comment to hide from older browsers
	//-->

 
</script>
</head>
 
<body onload="startMe();">
<img id="dhtmlFx" src="pennant2.gif" height="183" width="388" />
<div id="dhtmlText">0</div>
 
<form action="" name="animate" >
<input type="button" name="buttonStop" value="START" onclick="startThis();">
<input type="button" name="buttonStop" value="<<" onclick="slower();">
<input type="button" name="buttonStop" value=">>" onclick="faster();">
<input type="button" name="buttonStop" value="STOP" onclick="stopThis();">
</form>
 

</body>
</html>
 

 
Thanks!

modified 11-Jun-13 21:15pm.

AnswerRe: Calling a function from within a function question PinprofessionalDennis E White11-Jun-13 15:40 
AnswerRe: Calling a function from within a function question Pinmemberthanh_bkhn11-Jun-13 15:55 
GeneralRe: Calling a function from within a function question PinmemberCalufrax1213-Jun-13 15:25 
QuestionEnable / Disable textbox controlled by drop-down menu in PHP Pinmemberswapnilwebsite11-Jun-13 1:01 
Please answer for PHP
 
selecation is like
cse
mech
other
 
when other is selected textbox should have to be appere
QuestionSend Data to ASPX Page PinmemberASPnoob9-Jun-13 4:56 
Hi All,
How do I send data from a regular html page to an asp.net application using a button without requiring the user to enter anything into a textbox? All I want to do is use javascript to send a number or a string to an asp.net application when a button within an html form is clicked. Thanks in advance.
AnswerRe: Send Data to ASPX Page PinprofessionalDennis E White9-Jun-13 18:48 
QuestionActiveX Object in javascript can not create after host it Pinmemberkuntala kumari mahanta8-Jun-13 0:38 
Hi All,
I am using javascript to create a ActiveXObject. It runs well in one system. but after host it in IIS 7, when i run it from other computers ( http://ipaddress/sitenm) it can not create a ActiveXObject.
AnswerRe: ActiveX Object in javascript can not create after host it PinprofessionalDennis E White8-Jun-13 19:53 
GeneralRe: ActiveX Object in javascript can not create after host it Pinmemberkuntala kumari mahanta9-Jun-13 19:40 
GeneralRe: ActiveX Object in javascript can not create after host it Pinmemberdusty_dex9-Jun-13 22:13 
QuestionPassing Element ID to ASP.net [modified] PinmemberASPnoob7-Jun-13 16:31 
Hi All,
I am trying to send the value of the ID or Name attribute of an html form to ASP.net when the form button is clicked. Normally I would send data using textboxes, checkboxes, or radio buttons. I can also send values through the url but that is not safe. All I want to have on a form is the button and when it is clicked, send the value of the form's id attribute or form's name attribute to asp.net. The value of the id or name attribute will be generated using javascript at run time and not seen before the button on the form is clicked. Please give an example if you can, thanks in advance.

modified 7-Jun-13 23:26pm.

AnswerRe: Passing Element ID to ASP.net PinprofessionalDennis E White8-Jun-13 19:52 
GeneralRe: Passing Element ID to ASP.net PinmemberASPnoob9-Jun-13 1:55 
GeneralRe: Passing Element ID to ASP.net PinprofessionalDennis E White9-Jun-13 18:45 
QuestionAs Simple As I Can Make It - SOLUTION PinmemberJohn Simmons / outlaw programmer7-Jun-13 7:02 
Here's the code I ended up with (explanation follows code).
 
HTML (you may have to adjust for the versions of jquery and modernizr you're using):
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
    <title></title>
    <script type="text/javascript" src="../Scripts/modernizr-2.6.2.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-2.0.0.js"></script>
    <script type="text/javascript" src="TreeOfHope/jscripttest.js" ></script>
</head>
 
<body>
	<div id="canvasesDiv" style="position:relative; width:490px; height:356px; border:1px solid black; background-color:silver;"></div>
 
    <!-- what the image is supposed to look like -->
    <div id="testImage" style="width:490px; height:356px; border:1px solid black; background-color:silver;">
        <img src="http://paddedwall.org/2012mustang/images/blacklights_03.jpg" width="490px" height="356px;" alt="" />
    </div>
 
    <script type="text/javascript" > 
        $(document).ready(function()
        {
            doIt();
        });
    </script>
</body>
 
</html>
 
Javascript (jscripttest.js):
function doIt()
{
    var _filename      = "http://paddedwall.org/2012mustang/images/blacklights_03.jpg";
    var _divName       = "#canvasesDiv";
    var _sceneWidth    = $(_divName).width();
    var	_sceneHeight   = $(_divName).height();
    var _scaleX        = 1.0;
    var _scaleY        = 1.0;
    var _canvas        = null;
    var _context       = null;
 
    // create the image
    var _image = $('<img />')
    .attr(
    {
        'id'  : 'backgroundImage', 
        'src' : _filename
    })
    .css(
    {
        '-ms-interpolation-mode' : 'bicubic',
        'image-rendering'        : 'optimizeQuality'
    })[0];
 
    // load  it so we can get the scale
    $(_image).load(function()
    {
        if (this.complete === true)
        {
            Continue($(this)[0].naturalWidth, $(this)[0].naturalHeight)
        }
    });
 
    this.Continue = function(imgWidth, imgHeight)
    {
        _scaleX = _sceneWidth / imgWidth;
        _scaleY = _sceneHeight / imgHeight;
 
        _canvas = $("<canvas>Not html5-compatible</canvas>")
        .css(
        {
            'position': 'absolute'
            ,'top'     : 0
            ,'left'    : 0
            ,'z-index' : 0
            ,'display' : 'inline'
        })
        .attr(
        {
            'id'      : 'backgroundCanvas'
            // you have to set width/height as attributes instead of using css or the canvas 
            // won't scale correctly
            ,'width'  : _sceneWidth+"px"
            ,'height' : _sceneHeight+"px"
        });
 
        $(_divName).append($(_canvas)[0]);
 
        _context = $(_canvas)[0].getContext('2d');
 
        // we should only have to set the transform one time
        _context.setTransform(_scaleX, 0, 0, _scaleY, 0, 0);
 
        // and then we can draw all of our images at the desired location
        _context.drawImage(_image, 0, 0);
    }
}
 
The first problem was determining the actual "natural" size of the image. I had to put a call to subsequent code inside the call to image.load.
 
The second problem involved scaling the image to fit the desired size. Originally, I was using the jquery object's css() method to set the size of the canvas. When you do it that way, the canvas does not properly transform/scale. You MUST set the width and height as attributes in order to get scaling to work correctly.
 
Maybe this will help someone else in the future.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

AnswerRe: As Simple As I Can Make It - SOLUTION PinprofessionalDennis E White8-Jun-13 19:42 
QuestionCheckbox checked Java script and c# Pinmembersujeet3215-Jun-13 22:43 
Hello all,
 
How to invoke Code behind method and java script function
on check box change event
AnswerRe: Checkbox checked Java script and c# PinprofessionalDennis E White6-Jun-13 12:01 
Questionproblem with anonymus func with parameters Pinmemberimbaro2-Jun-13 21:27 
Hi, i have a problem.
i want to send a callback function with params.
and every time to send different params.
the problem is that the callback function recive all the time
the same values of the last iteration of the loop-
how can i solve this problem?
 
thnks!
 
 
function B(a,b)
{
    alert(a + b);
}
 
function A()
{
   for(var i = 0;i < Z ; i++)
   {
      for(var j = 0;j < Z ; j++)
      {
         var temp = function() {return function(){B(i,j)}};;
         func(temp);
      }
   }
}

AnswerRe: problem with anonymus func with parameters Pinmemberdusty_dex3-Jun-13 5:42 
QuestionRe: problem with anonymus func with parameters Pinmemberryanb313-Jun-13 7:29 
AnswerRe: problem with anonymus func with parameters PinmemberJohn Simmons / outlaw programmer6-Jun-13 4:35 
Questionhow to toggle between textbox and textarea by jquery Pingroupmhd.sbt30-May-13 8:21 
hi to all
i written some code for toggle between textbox and textare
but when my textbox convert to multi line(textarea) it cant be convert to input text again how can i do this
my html:
   <form id="form1" runat="server">
        <asp:TextBox ID="txt" runat="server" Text="11111111111111111111111111111"></asp:TextBox>
        <table class="auto-style1">
            <tr>
                <td>
                    <asp:TextBox ID="txt0" runat="server" Text="222222222222222222222222"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td><asp:TextBox ID="TextBox1" runat="server" Text="333333333333333333333333333"></asp:TextBox></td>
            </tr>
            <tr>
                <td><asp:TextBox ID="TextBox2" runat="server" Text="44444444444444444444444444444444444"></asp:TextBox></td>
            </tr>
            <tr>
                <td><asp:TextBox ID="TextBox3" runat="server" Text="5555555555555555555555555555555555555555"></asp:TextBox></td>
                <td> </td>
            </tr>
            <tr>
                <td><asp:TextBox ID="TextBox4" runat="server" Text="66666666666666666666666666666666666666666666"></asp:TextBox></td>
            </tr>
        </table>
    </form>
 $(function () {
        $(':input').click(function () {
            var newTextArea = document.createElement('TextArea');
            this.parentElement.appendChild(newTextArea);
            debugger
            newTextArea.name = $(this)[0].id;
            newTextArea.value = $(this)[0].defaultValue;
            newTextArea.onclick = function () {
                var newtext = document.createElement('input');
                newtext.value = this.innerText;
                newtext.name = this.name;
                this.parentElement.appendChild(newtext);
                $(this).remove();
            }
            $(this).remove();
        })
    });
thanks in advance
QuestionAs simple as I can make it PinmemberJohn Simmons / outlaw programmer30-May-13 8:03 
I'm still having problems:
 
0) The code will not get the width of the _image.
1) This in turn causes _scale to be "Infinity" (because _imageWidth is 0 when I try to do the division to determine _scale's value
2) Finally, the _context isn't drawing the _image.
 
If you want to try the code, I'm using jQuery 2.0 (prior versions back to 1.83 should work fine). Other than that, it's completely self-contained.
 
<body>
    <div id="canvasesDiv" style="position:relative; width:416px; height:512px; border:1px solid black; background-color:silver;"></div>
</body>
 
function doIt()
{
    var _filename      = "http://paddedwall.org/2012mustang/images/blacklights_03.jpg";
    var _divName       = "#canvasesDiv";
    var _sceneWidth    = $(_divName).width();
    var	_sceneHeight   = $(_divName).height();
    var _imageWidth    = 0;
    var _image = $('<img />').attr({'id': 'backgroundImage', 'src' : _filename})[0];
    $(_image).load(function()
    {
        if (this.complete === true)
        {
            _imageWidth = this.width;
            if (_imageWidth === 0)
            {
                _imageWidth = _sceneWidth;
            }
        }
    });
    var _scale = _sceneWidth / _imageWidth;
    var _canvas = $("<canvas>Not html5</canvas>");
    $(_canvas).css('width', _sceneWidth);
    $(_canvas).css('height', _sceneHeight);
    _canvas.attr('id', "backgroundCanvas");
    _canvas.css('width', _sceneWidth);
    _canvas.css('height', _sceneHeight);
    _canvas.css('position', 'absolute');
    _canvas.css('top', 0);
    _canvas.css('left', 0);
    _canvas.css('z-index', 0);
    _canvas.css("display", "block");
    $(_divName).append($(_canvas)[0]);
    var _context = $(_canvas)[0].getContext('2d');
    _context.setTransform(1, 0, 0, 1, 0, 0);
    _context.scale(_scale, _scale);
    _context.drawImage($(_image)[0], 0, 0);
}
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

AnswerRe: As simple as I can make it PinprofessionalManfred R. Bihy30-May-13 8:24 
GeneralRe: As simple as I can make it PinmemberJohn Simmons / outlaw programmer30-May-13 11:53 
AnswerRe: As simple as I can make it PinprofessionalRichard Deeming30-May-13 8:34 
GeneralRe: As simple as I can make it PinprofessionalManfred R. Bihy30-May-13 8:42 
GeneralRe: As simple as I can make it PinprofessionalRichard Deeming30-May-13 8:46 
GeneralRe: As simple as I can make it PinprofessionalManfred R. Bihy30-May-13 8:49 
GeneralRe: As simple as I can make it PinprofessionalRichard Deeming30-May-13 8:51 
GeneralRe: As simple as I can make it PinprofessionalManfred R. Bihy30-May-13 8:53 
GeneralRe: As simple as I can make it PinmemberJohn Simmons / outlaw programmer30-May-13 11:54 
GeneralRe: As simple as I can make it PinprofessionalManfred R. Bihy31-May-13 1:35 
GeneralRe: As simple as I can make it PinmemberJohn Simmons / outlaw programmer1-Jun-13 2:24 
GeneralRe: As simple as I can make it PinprofessionalRichard Deeming3-Jun-13 2:00 
GeneralRe: As simple as I can make it PinmemberJohn Simmons / outlaw programmer5-Jun-13 8:56 
GeneralRe: As simple as I can make it PinprofessionalRichard Deeming5-Jun-13 9:12 
GeneralRe: As simple as I can make it PinmemberJohn Simmons / outlaw programmer5-Jun-13 10:54 
GeneralRe: As simple as I can make it PinprofessionalRichard Deeming5-Jun-13 11:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 17 Jun 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid