|
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 ?
|
|
|
|
|
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">
<!--
var myFx;
currImage = "pennant2.gif";
xName = "dhtmlFx";
speedVar = 500;
speedVal = 100;
maxVal = 1500;
stopSpeed = 99999;
var startFlag;
startFlag = 1;
y = speedVar;
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);
}
</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.
|
|
|
|
|
I am assuming that you are trying to change the image based on some interval that you can control via user input. The initial image is most likely coming up but not the other.
The reason is because the second image has not been loaded.
You can either write some code to load the image or you can "stack" the two images and control their visibility via a style/css setting that you adjust during your interval calls.
Best of luck.
you want something inspirational??
|
|
|
|
|
Hi there, I think there is a problem when you call setSpeed():
You clear interval by calling
clearInterval(myFx);
This is the global myFx, but when you set a new interval, you return to a local variable
var myFx = setInterval(doFx,y);
If you remove the "var" in order to use the global myFx variable, the problem should be resolved.
myFx = setInterval(doFx,y);
|
|
|
|
|
Removing the redundant var fixed everything, I can't believe I hadn't noticed that...
Thanks much!
|
|
|
|
|
Please answer for PHP
selecation is like
cse
mech
other
when other is selected textbox should have to be appere
|
|
|
|
|
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.
|
|
|
|
|
I can't speak for all the people who helps on these message boards but reposting the same question will sometimes get you ignored.
Hopefully my latest response on your previous post helps.
As I tried to mention in both posts this question is best directed towards the ASP.Net forum.
Best of luck.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
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.
|
|
|
|
|
you are most likely running into security errors.
what exactly is the error you are creating when trying to create it??
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Thank u very much. There is no any error message, it runs well, problem is that it cant create ActiveX Obect. i tested the javascript code by giving alert message, the alert messages are comming, but the .exe which i am trying to call througt ActiveX Obeject cant create. i already done with all the settings in Internet Option in IE. (it runs well in one system and ActiveX Object is also created, but when i am trying to access it from other system it unable to create)
|
|
|
|
|
either,
a. ActiveXObject exists on the other machine but it hasn't been registered (using regsvr32)
or
b. ActiveXObject isn't on the remote machine at all and can't be registered until it does exist there
|
|
|
|
|
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.
|
|
|
|
|
First this question is probably best posted in the ASP Forum.
I am assuming that the button is an <asp:Button .../> and that you are handling that in a POST. If that is the case my recommendation would be stuff the value a textbox whose value is server readable. I might be entirely wrong but I believe the form tag is server rendered in ASP.Net in which case you don't want to mess with the name or the id because it could have a negative impact on the page gets marshaled back into code on the server.
As I said in the beginning this question is best if posted in ASP Forum.
Best luck.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Hi, thanks for your reply. Can't the button be a regular HTML button that uses a javascript function to send the values of the id or name attribute?
|
|
|
|
|
ASPnoob wrote: Can't the button be a regular HTML button that uses a javascript function to send the values...
Yes.
Again more directed towards the ASP.Net forum. The following article should help you get you started in the right direction towards what you are looking to do.
Calling Server Side Code from Client Side using Ajax[^]
Best of luck.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
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>
<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;
var _image = $('<img />')
.attr(
{
'id' : 'backgroundImage',
'src' : _filename
})
.css(
{
'-ms-interpolation-mode' : 'bicubic',
'image-rendering' : 'optimizeQuality'
})[0];
$(_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'
,'width' : _sceneWidth+"px"
,'height' : _sceneHeight+"px"
});
$(_divName).append($(_canvas)[0]);
_context = $(_canvas)[0].getContext('2d');
_context.setTransform(_scaleX, 0, 0, _scaleY, 0, 0);
_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
|
|
|
|
|
very cool... you should write an article on this.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Hello all,
How to invoke Code behind method and java script function
on check box change event
|
|
|
|
|
sujeet321 wrote: How to invoke Code behind method and java script function on check box change event
I am not sure what you meant by code behind... I am guessing ASP.NET in which case I would recommend you post this question in that forum.
I wrote this[^] quick sample on jsFiddle which does a simple jQuery setup to handle when a checkbox is selected.
http://jsfiddle.net/xehmr/[^]
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
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);
}
}
}
|
|
|
|
|
So where is func defined? where is Z defined?
What is your code supposed to do exactly?
here's some code.
function add(a,b)
{
alert(a + b);
}
function mult(a,b)
{
alert(a * b);
}
var o = { func : function(f, x,y) { return f(x,y); }};
function A(Z)
{
for(var i = 0;i < Z ; i++)
{
for(var j = 0;j < Z ; j++)
{
o.func(add, i,j);
}
}
} .
|
|
|
|
|
I would think you could debug and step through and see what is happening.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
When I define Z and func , the code runs, but B is never called. You have to provide a complete example.
".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
|
|
|
|
|
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
|
|
|
|