473,381 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,381 software developers and data experts.

Dynamically adding function to <DIV > element

prino
4
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".
  2.  
  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; }
  6.  
  7.     var onClickAction = 'scrollmain();';
  8.     thisContainer.onscroll = new Function(onClickAction);
  9. }
  10.  
  11. window.onload = function() { addIEonScroll(); }
  12. -->
  13. </script>
  14.  
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.

Robert
Attached Files
File Type: zip xml#1.d090227.exec.zip (3.5 KB, 180 views)
Feb 28 '09 #1
8 9998
acoder
16,027 Expert Mod 8TB
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. }
  6.  
  7. window.onload = addOnScroll;
  8.  
Feb 28 '09 #2
prino
4
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..   -->
Robert
Feb 28 '09 #3
acoder
16,027 Expert Mod 8TB
Does it scroll properly with the onscroll in the markup (but failing validation)?
Mar 1 '09 #4
prino
4
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.

Regards,

Robert
Attached Files
File Type: zip ehiasm.rex.t175123.zip (10.6 KB, 112 views)
Mar 1 '09 #5
acoder
16,027 Expert Mod 8TB
You could use Transitional instead. One other thing: IE doesn't support XHTML, so HTML should be fine.
Mar 4 '09 #6
prino
4
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. ;)

Robert
Mar 4 '09 #7
Dormilich
8,658 Expert Mod 8TB
@prino
because the MIME type is probably set to (or defaults to) text/html, which renders the document as HTML.
Mar 5 '09 #8
acoder
16,027 Expert Mod 8TB
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

3
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...
3
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...
2
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....
8
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...
2
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...
4
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...
0
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...
3
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.