Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:14:05+00:00 2026-06-08T20:14:05+00:00

I have this HTML code, which is invoking my javascript code. The code is

  • 0

I have this HTML code, which is invoking my javascript code. The code is for a gauge. In the javascript code, I am trying to access a SVG file, and modifying the needle (of the gauge) to display the desired value. The code is working fine. However, I do not wish to call onload(); and “object id” in HTML. I just want that as soon as my HTML file loads, javascript is invoked automatically. I do not want to call anything in html (no object id, no onload function) except headline in body tags. I tried various onload() methods, also tried this link
http://www.techrepublic.com/article/preloading-and-the-javascript-image-object/5214317
But not able to implement it. Any help would be highly appreciated.

PS : I tried my best to be as thorough in explaining the problem. However, please let me know if I am unclear somewhere.

This is Gauge.png image which is embedded in the svg code I have pasted below
https://sphotos-b.xx.fbcdn.net/hphotos-snc6/179594_10150982737360698_1827200234_n.jpg

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g name="gauge" width="122px" height="127px">
        <image xlink:href="gauging.png" width="122" height="127"/>
    <circle id="led" cx="39" cy="76" r="5" style="fill: #999; stroke: none">
        <animateColor id="ledAnimation" attributeName="fill" attributeType="css" begin="0s" dur="1s"
        values="none;#f88;#f00;#f88;none;" repeatCount="0"/>
    </circle>
        <g id="needle" transform="rotate(0,62,62)">
            <circle cx="62" cy="62" r="4" style="fill: #c00; stroke: none"/>
            <rect transform="rotate(-130,62,62)" name="arrow"  x="58" y="38" width="8" height="24" style="fill: #c00; stroke: none"/>
            <polygon transform="rotate(-130,62,62)" points="58,39,66,39,62,30,58,39" style="fill: #c00; stroke: none"/>
        </g>
        <text id="value" x="51" y="98" focusable="false" editable="no" style="stroke:none; fill:#fff; font-family: monospace; font-size: 12px"></text>
    </g>
</svg>

HTML+ Javascript Code

<head>
<title>SVG Gauge example</title>

<script>
function update1(){
    var scale=100;
    var value;
    var value1 = 69;

    var el=document.getElementById('gauge1');       
    if (!el) return;

    /* Get SVG document from HTML element */
    var svg_doc = el.contentDocument;
    if (!svg_doc) return;


    /* Rotate needle to display given value */
    var needle_el = svg_doc.getElementById('needle');
    if (!needle_el) return;
    /* Calc rotation angle (0->0%, 260->100%) */
    value = parseInt(value1);
    scale = parseInt(scale);
    if (value > scale) value = scale;
    var angle = value / scale * 260;
    /* On-the-fly SVG transform */
    needle_el.setAttribute('transform','rotate('+angle+',62,62)');
}
</script>

</head>
<body onload="update1(); ">
<div>
<object id="gauge1" type="image/svg+xml" data="gauge.svg" width="127" height="122"/>
</div>
</body>    

</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:14:06+00:00Added an answer on June 8, 2026 at 8:14 pm

    To avoid the onload attribute, you can use the load event:

    <script type="text/javascript">
        function update1() {
            // ...
        }
    
        document.addEventListener('load', update1, true);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which can display drop down in div tag of html.
I have this code which is in HTML; <div id=progress_info class=success style=display: block;> ‌·‌·‌·
I have this HTML code which simulates a dropdown multi-checkbox <div> <div class=select> <span>Select
I have a td-element which can contain some HTML code, e.g. &lt; . This
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have a HTML code which looks like this. <html><head><meta http-equiv=refresh content=0;url=http://www.abc.com/event/></head></html> I want
I have this legacy code which embeds an SWF into an HTML using an
I have this code which is not working jQuery if($(#dis(h3)).length == 0) $(#dis).append(<p>no display</p>);
I have this code which getting html code of page and than replace all
I have this code which calculate route between tow places function createDrivingRoute() { $(#nav).html();//CLEAR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.