473,787 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it possible to force re-avaluating/re-parsing of HTML?

Hi,

Ran into the following problem while trying to have a code to
attach a Virtual Keyboard to any user's form:

User clicks a button and my JavaScript changes outerHTML
of say <textarea - adding things like ONCLICK='saveCa ret(this)'
etc. and it also tries to save any text that user could've entered
before the button press.

a) Value - (already typed text) is not assigned back
b) outerHTML is still the same - both in alert() text and via
javascript:x=do cument.body.inn erHTML.replace(/</g,'&lt;').repla ce(/\n/g,'<br>'); document.body.i nnerHTML = x;
The code is simple so I wander whether we have a way to force HTML to be
re-avaluated/re-parsed via a button click

(if I do the same via <script....</scriptline placed above the button
then everything is OK - because HTML is being changed _before_ the
page load is over)

=============== =============== =========
function vkb_addAttribut es(obj)
{

var obj_value = ""; if (obj.value != "") obj_value = obj.value;
var kA=" onFocus='vkb_tx tControl=this;' OnSelect='vkb_s aveCaret(this)' ";

var obj_HTML = obj.outerHTML;
var pos = obj_HTML.indexO f('>');
var part1 = obj_HTML.substr ing(0,pos);
var part2 = obj_HTML.substr ing(pos);
obj.outerHTML = part1 + kA + part2;

obj.value = obj_value;
}
=============== =============== ===============

Thanks,
Paul
Sep 25 '06
51 4428
GLC
I apologize for my incoherent blabber.
I meant that the event object does not have to be specified or passed
in.
But, you are correct that the function definition must include a
parameter to receive the event if it IS passed in, which is the case
with non-IE browsers.
Thus, in my example where I am using a function reference to attach an
event handler, I am not including a parameter, because one cannot be
used for function references; and yet, the function definition does
have a parameter, which may or may not be used depending on the
browser.

Event handling and asynchronous function calls are so easy to
understand, I am surprise we are even having this discusion. ;-) j/k
On Oct 6, 4:13 pm, Paul Gorodyansky <paul...@compus erve.comwrote:
GLC wrote:
No, it is not IE only.
e is passed in as a parameter for non-IE browsers.
That line checks if e exists before using the IE only windows.event.T hen it's a contradiction where it's a MUST to have parameter or not:
e is passed in as a parameter for non-IE browsers.and
For dynamically added event handlers; neither the event nor the element
triggering the event NEED to be passed.?

--
Paul
Oct 6 '06 #31
GLC wrote:
>
I apologize for my incoherent blabber.
I meant that the event object does not have to be specified or passed
in.
But, you are correct that the function definition must include a
parameter to receive the event if it IS passed in, which is the case
with non-IE browsers.
Thus, in my example where I am using a function reference to attach an
event handler, I am not including a parameter, because one cannot be
used for function references; and yet, the function definition does
have a parameter, which may or may not be used depending on the
browser.

You mean, non-IE browsers would not midn the following?

1) No parameter (can not be)

txtControl.oncl ick=myFunction;

2) There is a parameter and my function magically knows that it's
event
function myFunction(evt) {...}

Right?

Aslo, Keith never wrote a demo/explanation for his package so I still
don't get how to obtain an object where the even handler is working
if there is no 'this' parameter.

--
Thanks,
Paul
Oct 6 '06 #32

Just to clarify - the discussion is now around the fact that
one can add an evenhandler (we are talking cross-browser, not jsut iE)
by

txtControl.onfo cus=myFunction;

but only with _that_ syntax, i.e. NO parameters.

It then contradicts with your (unless I am missing something) phrase
about non-IE browsers _passing_ the parameter:
But, you are correct that the function definition must include a
parameter to receive the event if it IS passed in, which is the case
with non-IE browsers.
?

--
Paul
Oct 6 '06 #33
Paul Gorodyansky wrote:
>

You mean, non-IE browsers would not mind the following?

1) No parameter (can not be)

txtControl.oncl ick=myFunction;

2) There is a parameter and my function magically knows that it's
event
function myFunction(evt) {...}

ad not say a variable that sets a color of my button? :)

--
Paul
Oct 6 '06 #34
Paul Gorodyansky wrote:
GLC wrote:
>>I apologize for my incoherent blabber.
I meant that the event object does not have to be specified or passed
in.
But, you are correct that the function definition must include a
parameter to receive the event if it IS passed in, which is the case
with non-IE browsers.
Thus, in my example where I am using a function reference to attach an
event handler, I am not including a parameter, because one cannot be
used for function references; and yet, the function definition does
have a parameter, which may or may not be used depending on the
browser.

You mean, non-IE browsers would not midn the following?

1) No parameter (can not be)

txtControl.oncl ick=myFunction;
Parameters are irrelevant here, 'myFunction' is the function reference.
2) There is a parameter and my function magically knows that it's
event
function myFunction(evt) {...}
It doesn't magically know, it is passed when then event handler is called.

Modern browsers call event handling callbacks with an event object as
their parameter, IE calls them with window.event as the event object.

--
Ian Collins.
Oct 6 '06 #35
Ian Collins wrote:
>
1) No parameter (can not be)

txtControl.oncl ick=myFunction;
Parameters are irrelevant here, 'myFunction' is the function reference.
2) There is a parameter and my function magically knows that it's
event
function myFunction(evt) {...}
It doesn't magically know, it is passed when then event handler is called.

Modern browsers call event handling callbacks with an event object as
their parameter, IE calls them with window.event as the event object.
So non-IE browser while looking at that function definition - say
function myF(parA, parB, parC)

ALWAYS assumes that parA is event
and in the 'body' of that function I can use say

if (parA.ctrlKey)
return true;

?

Then it _is_ a magic :) So, always parameter #1? Or it's allowed
to have only one parameter at that's it? And the assumption that
it's event ?

Or you are saying that NO parameters are needed in the function
_definition_ - just

function myF()
{
}

and event is a pre-set, special name that can be used
like this

if (event.ctrlKey)
return true;

?

Presently I have say (event is 2nd parameter)

<textarea .... onkeypress=vkb_ changeKey (this, event)

with parameters being set and used like this:

function vkb_changeKey (txtControl, evt)
{
if (evt.ctrlKey)
return true;
}

*************** *************** ****

So you guys are saying that it's possible to do the same

by

txtObject.onkey press=vkb_chang eKey;

and use some other methods for getting hold of text Object
(with the lcuk of 'this' as a parameter)
and use some other methods of using event ?
---
Thanks,
Paul
Oct 6 '06 #36
Paul Gorodyansky wrote:
Ian Collins wrote:
>>>1) No parameter (can not be)

txtControl.o nclick=myFuncti on;

Parameters are irrelevant here, 'myFunction' is the function reference.

>>>2) There is a parameter and my function magically knows that it's
event
function myFunction(evt) {...}

It doesn't magically know, it is passed when then event handler is called.

Modern browsers call event handling callbacks with an event object as
their parameter, IE calls them with window.event as the event object.


So non-IE browser while looking at that function definition - say
function myF(parA, parB, parC)

ALWAYS assumes that parA is event
and in the 'body' of that function I can use say

if (parA.ctrlKey)
return true;

?

Then it _is_ a magic :) So, always parameter #1? Or it's allowed
to have only one parameter at that's it? And the assumption that
it's event ?
Do you have a book on JavaScript? If not, I'd recommend David
Flanagan's "JavaScript The Definitive Guide" where all these concepts
are explained.

--
Ian Collins.
Oct 7 '06 #37
Ian Collins wrote:
>
Do you have a book on JavaScript? If not, I'd recommend David
Flanagan's "JavaScript The Definitive Guide" where all these concepts
are explained.
Thanks, I'll do that - before I just used Web materials - thinking,
"if I know how to program in C or C++ then I can program in JavaScript
especailly because it's a _hobby_ (Virtual Keyboard) -
by just looking at Web examples and FAQ".

Kind of worked :)

But it looks like now it's time for learning more deep concepts...
--
Regards,
Paul
Oct 7 '06 #38
Paul Gorodyansky wrote:
Ian Collins wrote:
>>Do you have a book on JavaScript? If not, I'd recommend David
Flanagan's "JavaScript The Definitive Guide" where all these concepts
are explained.


Thanks, I'll do that - before I just used Web materials - thinking,
"if I know how to program in C or C++ then I can program in JavaScript
especailly because it's a _hobby_ (Virtual Keyboard) -
by just looking at Web examples and FAQ".
That (C and C++) is my background as well and it took me a while to
break loose of the shackles imposed by a strongly typed, class
inheritance mindset.
Kind of worked :)

But it looks like now it's time for learning more deep concepts...
In the case of the above book, 590 well written pages of them :)

--
Ian Collins.
Oct 7 '06 #39
Hi,

GLC wrote:
...
To add an event handler: EventManager.Ad d(tmpImg, "click", saveItem,
false);
Then in the called function:
function saveItem(e){
// get target button
var targ;
if (!e) var e = window.event;
if (e.target) targ = e.target;
else if (e.srcElement) targ = e.srcElement;
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode ;
...
Thanks, it works - if it's just a function that I want to have in a new
eventhandler added to object, but I can not figure out what to do
if it's not

<textarea onkeypress=myFu nction(this, event)

but several things like (what to do with return ?):
a)
<textarea onkeypress={myF unction(this, event);x=f2(thi s);return false;}

or

b)
<textarea onkeypress={ return myFunction(this , event); }
--
Regards,
Paul
Oct 10 '06 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1566
by: infidel | last post by:
I may have found the source of my infinite loop when importing kid modules from my cherrypy server. Here is some code from the autoreloader module of cherrypy: def reloader_thread(): mtimes = {} def fileattr(m): return getattr(m, "__file__", None)
3
6358
by: Clark Spencer | last post by:
I have built a small integration app using VS .NET 2003 that extracts orderinformation from a 'webshop'. Extracting the orderinformation works fine. Appending the order elements in the XmlDocument was also done in a jiffy. The final step is to save the document to disk and then ship it to another system using ftp. The xml orderfile produced must fit a set specification of the recieving system. That specification states that empty elements...
5
1174
by: craig | last post by:
Assume that you have a User object, which abstracts an authenticated user of your application. It has some properties such as UserID, FirstName, LastName, etc. and a method LogOut(); The LogOut method logs the user out of the application. If the LogOut() method is successful, the user is logged out and the User object should no longer be valid. Is there a way to allow the LogOut() method to force the reference that is being held to the...
2
2970
by: Steve Franks | last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting a value in the config.web file. However, what if I wanted to determine at run time whether or not I wanted to use cookieless sessions for a particular user, and if so, I'd instruct ASP.NET to turn on cookieless sessions for a particular user session. Is this possible? For example I want to use cookie based sessions by default for all users. But if a user has...
1
2907
by: nightowlky | last post by:
Is it possible to force a file (opened on a local drive of a machine) to be closed in order that it may be written to with updates?
1
3914
by: Mark A | last post by:
DB2 ESE 8.2.3 (FP10) for Linux We are experiencing a connection hang of 10 - 15 minutes in the following HADR and automatic client reroute scenario: 01 server is primary database 02 server is standby database a. applications connected to database on 01 server b. shutdown 01 server
11
1493
by: gregory_may | last post by:
Is it possible to force a limit on the amount of CPU a task is taking? I am thinking of writing a simple app that will let me force other applications to "be nice" by only using so much CPU. Is this possible ... does anything like this exist?
0
2662
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button, when you press it it should generate search results in a new page. However, when you click the "Generate Report" submit button, the moment you try to THEN click the "Search" submit button, the "Search" submit button NEVER goes to a new page but...
0
859
by: scoe | last post by:
In designing a application to update firmware, I require to reset the hardware. Is their any command or method to force a reset of the device.
6
3508
by: Hubert Fritz | last post by:
Hello, I fear I want to have something which is not possible in C++. How is it possible to define a base class so that the derived class is forced to contain a static member variable, which can be used by static member functions of the base class? Something like virtual static XClass* pXClass; /* pXClass shall be pure virtual, so not static in base class, but
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.