|
Thanks for your reply Richard,
I understood the sequence but there's still something not clear for me.
A variable which holds a reference, basically holds a pointer to an object.
If I set variable 'a' which holds a reference to object1 to a new variable called 'b', both of them
will have a pointer that should point to the same place i.e. object1.
Maybe I'm confusing it with a language like c# but if I set a new object to variable 'a' called 'object2',
I'm creating a new pointer to that new object. I expect the place in memory where the original pointer which pointed to 'object1' will change and point to object2 for both 'a' and 'b'.
But I see that's not happening.
'a' points to the new object while 'b' still points to the older one.
|
|
|
|
|
No. If variables a and b point to object1 , and you change variable a to point to object2 , variable b will not be affected.
If you're more comfortable with C#, consider the following contrived example:
string a = string.Empty;
string b = string.Empty;
a = "Hello";
What value do you think will be in b after you run this code?
If the language followed your idea, since both variables start out pointing to the same string, when you change a to point to the string "Hello" , it would automatically change b as well. That would make it virtually impossible to write a program, since all variables and fields of the same type would automatically be pointing to the same instance of that type.
Think of it like postal addresses: person a lives at address1 , and person b also lives at address1 . If you change the street-name for address1 , that change affects both people. If person a moves to address2 , that doesn't necessarily mean that person b moves as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Great, that was a good explanation.
Thanks Richard!
|
|
|
|
|
constructor of "ype "m" is function manager(){...}
m = new constructor (...)
m is a pointer !
e.g. new Function(...) creates a pointer of a function
new Function() is a member of Javascript predefines types (predefined constructor)
so manager() runs like new Function() ?
function manager()
{
var anObject = {prop1: 1, prop2: 2};
// local var !!!!
// does not exists after the end of constructor
// use global var !
.
.
.
return
{
getMyObject: function(){
return anObject;
}
// local function !!!!
// does not exists after the end of constructor
// use global var to save the pointer.
}
|
|
|
|
|
Hi All
I need to emulate bandwidth throttling scenario on my web application, I have two buttons, when user click on first button then play a video from my server, this should be poor user experience (through bandwidth throttling on this session between my laptop and my web server)
On the other hand when user clicks a second button, and then play same video(HTML5 video), then better quality of experience should be observed,
Is there a way I can achieve this using java-script?
|
|
|
|
|
readystatechange event ist useable for AUDIO, see
http://msdn.microsoft.com/en-us/library/hh772923%28v=vs.85%29.aspx
javascript runs only on client, sou you must use interface to catch state of an element
its events like readystatechange-event
|
|
|
|
|
Hi
I have worked in front end but in the company I worked we don't do any cross browser compatibility.
How we can do the cross browser compatibility.
What are the steps? it is a interview question
Can anybody help with it.
Thanks,
Mary Abraham
|
|
|
|
|
|
Thanks Peter I got an Idea.
Mary Abraham
|
|
|
|
|
If you need to access to a server that don't support CROS and that your data is not sensitive (public data like weather, music info or anything) you can try this :
CROSProxy[^] you'll not have to change your source code also !
|
|
|
|
|
Create a super class ComputingMachine. This class should be designed as parent class of any kinds of computing devices like calculators, timers, mobile phones, etc. Computing machines’ basic attributes includes its manufacturer’s name, product code and classification. You may wish to add more attributes. Along with all the basic methods (constructor, accessor, mutator, output, comparison, and other helper methods), define a method compute() which has nothing to do yet. This method will be overridden in future subclasses.
Extend the ComputingMachine class to two subclasses, Calculator and Timer. Add the necessary attributes and methods for them. These subclasses must implement the BasicOp interface which you must create. The BasicOp interface will require the implementation of methods plus(), minus(), times(), and divideby(). If any one of these methods are not applicable to the class which implements it, the class must be able to handle it.
In the demo class, calculator object must be able to continuously perform the BasicOp methods for two operands until the method compute is invoked, behaving like a simple calculator of the real world.
Timer object in its own demo class, must perform as a countdown timer or a usual lapse timer depending on the users choice.
roni
|
|
|
|
|
Don't repost questions[^], In Q/A section some people made comments to your question. Read that again.
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
Is there a question or are you looking to hire someone?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How to do the method compute() ?
|
|
|
|
|
What do you mean?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Are you sure this is a Javascript question?
|
|
|
|
|
Good Day All
i am opening a Popup and i want to bind the "onbeforeunload" to the popup that if someone clicks on the close button in the window or close button in the page , the event should fire a javascript function that is on the page that opened the popup.
function ProcessPayment(Downloadurl)
{
var url = "http://XXXX.com/cccc_ccccc/2938dc870cd394?tc_id=210&tc_45f=50.0&sig=fc5cbfe44230";
var popupWindow = window;
popupWindow.onbeforeunload = function () {
if (Downloadurl != "") {
$.fileDownload(Downloadurl)
.done(function () { alert('File download a success!'); })
.fail(function () { alert('File download failed!'); });
}
else {
alert("No URL found");
}
}
popupWindow.open(url, 'popUpWindow', 'height=400,width=500,left=10,top=10,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
when i try this nothing happens the event does not get work and no error in the browsers console
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Please do not use pop ups!
Popups are a very ugly way of shoving some data into the users face, in a way he probably doesn't like and didn't ask for. The only thing that should open a new window or tab is me middle-clicking (or right-clicking) a link. Everything else should stay in the existing window.
|
|
|
|
|
hi Nicholas
I am building a mobile app using cross-platform mobile development toolkit, so this is something that gets popup when a third-party payment is required.
thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Our app uses popups all the time. It works like Microsoft CRM. When you double-click a grid record we open the record maintenance in a popup.
Popups have their place but they did get a bad name because of people misusing them.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
hi Kornfeld
let me have a look at the link you sent.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
I'm pretty sure that event has to be in the window itself, you can't attach your own. I could be wrong though.
Also, popupWindow.open() can be done modally so you can get the return value from it. If the return value is null, depending on the window, that could be the indication you are looking for.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hi
I am new user I want to open file on network drive like \\10.30.50.88\project\test\product\Daily\Reports\form.html and try to save on \\10.30.50.88\project\test\product\Daily\Reports\data.txt
But when Click on submit button it show error message
Error: Number:-2146827859 Description:Automation server can't create object
Please help me out . I want to replace “d:\\data.txt “ with “\\10.30.50.88\project\test\product\Daily\Reports\data.txt “
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
<SCRIPT LANGUAGE='JavaScript'>
function WriteToFile() {
try {
var fso, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
s = fso.OpenTextFile("d:\\data.txt" , 8, true, 0);
s.writeline(document.ietmdata.name.value + ", " + document.ietmdata.email.value + ", " + document.ietmdata.location.value + ", " + document.ietmdata.type.value );
s.Close();
}
catch(err){
var strErr = 'Error:';
strErr += '\nNumber:' + err.number;
strErr += '\nDescription:' + err.description;
document.write(strErr);
}}
</SCRIPT> </head>
<BODY>
<form action="test.hta" method="post" name="ietmdata" >
Name: input type = "text" name="name"<br>
Email: input type="text" name="email"<br>
Location: input type = "text" name="location"<br>
Type: <select name="type" >
<option value="Software"> Software </option>
<option value="Hardware"> Hardware </option>
</select>
<br><br>
<INPUT TYPE=BUTTON VALUE="Submit Data to Text File" önClick="WriteToFile(this.form)">
</form>
</body></html>
|
|
|
|