Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

anything simpler than document.write() ?

Options
  • 09-08-2004 12:19pm
    #1
    Registered Users Posts: 1,278 ✭✭✭


    i'm porting over a college project ( current version can be viewed online at http://www.thegalwaysky.com/starcheck/ ) from ASP to a pure client-side JavaScript application.

    i was wondering if there is a simpler way of writing variables within the body of an html document than every time having to use:

    <script language="JavaScript1.5">
    document.write(myVar);
    </script>

    asp and php have useful shortcuts for writing the values of variables within the html body, eg. <%= myVar %> for ASP. can something similar be done with JavaScript ?

    cheers,
    jAH


Comments

  • Registered Users Posts: 8,452 ✭✭✭Time Magazine


    Try

    var d.w = document.write;

    then try d.w.(myVar);

    Alternatively make a function, e.g. x(myVar), whose command is simply to document.write(). So you get <script>x(myVar)</script> each time. It's a little easier.


  • Registered Users Posts: 1,278 ✭✭✭jArgHA


    cheers banana,

    the x(myVar) function sounds good although i thought there may have been a shortcut for getting rid of the <script> tags also (as in ASP/PHP). ps nice website you've got there.

    grma,
    jAH


  • Registered Users Posts: 1,967 ✭✭✭Dun


    The javascript tags/source can't be removed because the browser runs the javascript on the client computer, whereas PHP/ASP is processed on the server. Angry Banana's is probably the neatest way of handling what you're doing.


Advertisement