Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1

    Default How to know if javascript is executing?

    There are several references on this forum to modifying a page's behavior by placing html of the following form in the body of a page:
    <script type="text/javascript">xr_v1(document.getElementById('message ').parentNode.parentNode)</script>
    Although I've following the "instructions" for using it, I have seen no evidence that it actually works or is even executing ... which leads me to these questions:

    Is there a statement I can add to that block that would display a message or change a color ... or something?
    xr_v1 appears to be a function. Where might I find it documented?
    When such a script is in the body html, when is it executed?

    As you can tell, I'm not versed in javascript. And it's tough to get even a toehold when viewing resources like W3School. But I'm trying to learn.

    Thanks in advance for any assistance.

  2. #2
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: How to know if javascript is executing?

    I normally follow siran or Acorn when it comes to JS Contours, I just dabble (badly).

    However copy the following text, paste it into Notepad, save it as test.html & run it in a browser.

    <html>
    <body>

    <p id="p1">What's your name?</p>
    <button type="button" onclick="myFunction()">Answer</button>
    <p><p/>
    <button type="button" onclick="myFunction2()">Reset</button>

    <script>
    function myFunction() {
    document.getElementById("p1").innerHTML = "Contours";
    document.getElementById("p1").style.color = "blue";
    }

    function myFunction2() {
    document.getElementById("p1").innerHTML = "What's your name?";
    document.getElementById("p1").style.color = "red";
    }
    </script>

    </body>
    </html>
    Getting that to work in Xara isn't within my knowledge.
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #3

    Default Re: How to know if javascript is executing?

    @Egg: Thanks for that sequence. It's easy to follow what it does when opened in a browser. It's certainly a good start.

    As a test, I named one of the page's text fields "text" and made a crude attempt at grafting one statement into the snippet in the page body ... without any result.
    <script type="text/javascript">xr_v1(document.getElementById('message ').parentNode.parentNode);document.getElementById( "text").style.color = "red"</script>
    If it's even possible to do this, maybe someone can correct my syntax error(s).

    I appreciate your help.

  4. #4
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: How to know if javascript is executing?

    Don't know how you attach the code to Xara Buttons but this works with html generated buttons.
    Attached Files Attached Files
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  5. #5

    Default Re: How to know if javascript is executing?

    Yes, it does work as you've described. But when I attempted to adapt a single statement into a super-simple test case:
    <script>document.getElementById("text").style.colo r = "red"</script>
    ... nothing changed. I suspect I'm not in the right ballpark with the syntax.

    Thanks for posting the example. I'll continue to look for other examples of "body html" to get a handle on uses.

  6. #6
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: How to know if javascript is executing?

    [QUOTE]<script>document.getElementById("text").style.co lo r = "red"</script>[/QUOTE

    Try

    document.getElementById("text").style.color = "red";

    thats without the gap between the o and r in color and the semicolon on the end.
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  7. #7
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: How to know if javascript is executing?

    Seems to me the original insert
    that you have a space in 'colo r' maybe not picking that script up due to the space..
    Jim
    Intel i7-2600 processor 3.4GH, Windows 10 64Bit, 12GB Memory, Geforce 960 2Gb graphics card

  8. #8

    Default Re: How to know if javascript is executing?

    @Scotty: those occasional blanks are inserted by the forum software ... to keep text strings from being too long to wrap, I believe.

    @egg: I got the result shown below. In a way, it gives a hint as to how the body html is interpreted. I'm still at a loss of how to get it to tell the browser that I want a different result than what is defined in the xara-built html. Am I looking at this all wrong? If I am, how do scripts in the body html modify elements like slider widgets?

    Thanks for the responses.


    Click image for larger version. 

Name:	Page result.PNG 
Views:	71 
Size:	5.8 KB 
ID:	114521

  9. #9
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: How to know if javascript is executing?

    I believe the space is down to a glitch in the forum quote Jim. I tried editing and it added more spaces.

    Contours, try the attached.
    Attached Files Attached Files
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  10. #10
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,917

    Default Re: How to know if javascript is executing?

    Contours, are you also naming the text block "HTMLBlockText" ?
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	names.png 
Views:	70 
Size:	11.5 KB 
ID:	114523  
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •