473,695 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically adding function to <DIV > element

4 New Member
Hi all,

I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF editor. A fellow member of the PCG has helped me by creating a bit of Javascript to emulate the scrolling and using Google I've now gotten it into a state where it almost passes the W3C Markup Validation Service. However, the one error,
Expand|Select|Wrap|Line Numbers
  1. Error  Line 166, Column 28: there is no attribute "onscroll".
  3. <div id="mainarea" onscroll="scrollmain();">
seems to defy all my attempts of killing it. I've Googled myself silly, there are lots of links to dynamically modifying DOM elements and I've even found a link in my bookmarks to (Almost) Pure CSS Scrollable Table with Fixed Header, which contains such code. Reduced to what I need, and with re required function-name changed to what I needed, it looks like

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. function addIEonScroll() {
  4.     var thisContainer = document.getElementById('mainarea');
  5.     if (!thisContainer) { return; }
  7.     var onClickAction = 'scrollmain();';
  8.     thisContainer.onscroll = new Function(onClickAction);
  9. }
  11. window.onload = function() { addIEonScroll(); }
  12. -->
  13. </script>
But it doesn't work (we're talking Firefox 3.0.6) and I end up with a non-scrolling left column (the one with the sequence numbers).

Also, the attached file (with onscroll in the &lt;div&gt; element) loads flawlessly in FF and IE(6), but if I take a somewhat larger (as in 10,000) line file, loading in FF takes a bit longer (~ 10 seconds), but IE6 completely hangs, tried this earlier today before taking the dog for a walk, two hours later it was still no further...

Any hints would be most welcome.

Attached Files
File Type: zip xml#1.d090227.exec.zip (3.5 KB, 181 views)
Feb 28 '09 #1
8 10039
16,027 Recognized Expert Moderator MVP
You should be looking to add it like this:
Expand|Select|Wrap|Line Numbers
  1. function addOnScroll() {
  2.     var thisContainer = document.getElementById('mainarea');
  3.     if (!thisContainer) { return; }
  4.     thisContainer.onscroll = scrollmain;
  5. }
  7. window.onload = addOnScroll;
Feb 28 '09 #2
4 New Member
Nope, here is the diff, result is, as expected, because I think this is essentially what I already did, that the sequence-numbers column no longer scrolls. :(

Expand|Select|Wrap|Line Numbers
  1. 6a7,17
  2. > <script type="text/javascript">
  3. > <!--
  4. > function addOnScroll() {
  5. >      var thisContainer = document.getElementById('mainarea');
  6. >      if (!thisContainer) { return; }
  7. >      thisContainer.onscroll = scrollmain;
  8. >  }
  9. > window.onload = addOnScroll;
  10. > -->
  11. > </script>
  12. >
  13. 166c177
  14. < <div id="mainarea" onscroll="scrollmain();"><span id="topofdata">***************************** Top of Data ******************************</span><!-- Formatted data follows; do NOT break this line apart or insert additional line breaks..   -->
  15. ---
  16. > <div id="mainarea"><span id="topofdata">***************************** Top of Data ******************************</span><!-- Formatted data follows; do NOT break this line apart or insert additional line breaks..   -->
Feb 28 '09 #3
16,027 Recognized Expert Moderator MVP
Does it scroll properly with the onscroll in the markup (but failing validation)?
Mar 1 '09 #4
4 New Member
Yes, it does, that's what's so very annoying! I've made some more changes to it and this is the only thing that stops it from validating error-less for XHTML 1.0 Strict. Very frustrating! New file is attached, bit bigger, has another problem in that it kills off IE6.


Attached Files
File Type: zip ehiasm.rex.t175123.zip (10.6 KB, 113 views)
Mar 1 '09 #5
16,027 Recognized Expert Moderator MVP
You could use Transitional instead. One other thing: IE doesn't support XHTML, so HTML should be fine.
Mar 4 '09 #6
4 New Member
IE7 doesn't complain about XHTML and the good news is that I've solved the problem, if validates errorless right now. Rather than trying to add the 'onscroll' to the code in the earlier attachment, I've now added

Expand|Select|Wrap|Line Numbers
  1.   var thisContainer = document.getElementById('mainarea');
  2.   if (thisContainer) 
  3.     { 
  4.      var onClickAction = 'scrollmain();';
  5.      thisContainer.onscroll = new Function(onClickAction);
  6.     }  
as the first statements in the function 'setwidth' near the bottom and that works, making me a pretty happy bunny. ;)

Mar 4 '09 #7
8,658 Recognized Expert Moderator Expert
because the MIME type is probably set to (or defaults to) text/html, which renders the document as HTML.
Mar 5 '09 #8
16,027 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. thisContainer.onscroll = scrollmain;
should be enough for lines 3-6. It should've worked onload, but since you've found a reasonable alternative, that's not a problem. Did you manage to solve the IE6 loading problem?
Mar 5 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Jens Kristensen | last post by:
I have a problem displaying a divbox containing a html-textarea - everything works fine with "normal" characters. However, when the textarea contains special chars like <P> or ' , the box fails to show: function show(divbox) { divbox.style.display=''; } <div id="divbox" style="display:none" >
by: bissatch | last post by:
Hi, I have the following page: www.martynbissett.co.uk/index_div.html It is very basic that all elements will be structured using <div> tags and CSS styles will define the layout. What I dont know how to do is align the wrapper <div> (#maindiv) center. How is this done?
by: brw | last post by:
Is there a way to dynamically add a link tag to the head block of an ..aspx page? I'm aware that you can add a link tag (or literal control) statically and then dynamically modify the attributes. I'm wondering if there's a way to add the tag from scratch at run time. thanks, Ben
by: localhost | last post by:
I would like to wrap all of the HTML inside of my <body> tag inside a <div> with in my code-behind. I do not want to touch the .aspx page template at all. I know how to make the body tag runat=server and give it an id so I can find it from the code-behind, but after that I want to add the <div>. One problem I see is that I just add the <div> to the <body>, all of the other controls (including the aspx <form>) will not be inside it. What...
by: Daves | last post by:
I find this odd; to create a DIV (html) element I use the HTMLGeneric control; <div ID="myDiv" runat=server ... This has no .Text property such as myDiv.Text = "testing"; So I am forced to use the Label control instead but that one results in a <span> element for which many style attributes cannot be used, e.g.
by: Alan Silver | last post by:
Hello, I would like to know if it is possible to use a panel, but prevent it from adding a <div> tag to the HTML. The reason I want to do this is that I am using a panel to enable me to show/hide part of a page as required. I would like the part in the panel to appear on the same line as the controls that precede it, but when the panel is converted to HTML, a <div> tag is used, and that forces a new line in the browser. Any ideas? TIA
by: msch-prv | last post by:
How to maintain the display state of a <divelement? Is there a simple way to maintain the display state of a <div> element? On my page, a div block can be hidden/shown by js function showhide(). I would like to maintain the block's display state when the page is posted back. I'm having difficulties to retrieve the div style attributes from the viewstate: Me.divProdCat.Style.Item("display") always returns the same attribute.
by: abhishekoza | last post by:
Hi, I am developing a website . The home page contains 10 different html templates. What I need to do is that i want to access a div tag from a template which is defined in another html template. I tried document.getElementById('d').innerHTML="some text"; but it is showing null. Is there any way to define <div> as global so it is accessible from any other html template.
by: turgon | last post by:
At the moment I making an ajax based file manager system. Im approched by a tricky problem. As in windows explorer etc I want users to be able to select any free space, click down, and drag a semi-transparent box around that will automaticly select any file/folder elements it covers over. In a more general sense, take this tutorial page with the three movable objects. I can lift Item 1 and place it over Item 2. But can I use javascript now,...
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...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
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.