473,386 Members | 1,828 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,386 software developers and data experts.

declare variables document.write()

function myFunction(){
document.write('var path="../images/2008/');
}
I use this kind of function to declare the variable path. It's on a
extern javascript file. If I use this function in an other function to
define var path, the result is an error: path not defined. Can someone
explain to me why this doesn't work?
Nov 18 '08 #1
1 2320
On Nov 18, 4:00 pm, Jean wrote:
function myFunction(){
document.write('var path="../images/2008/');}

I use this kind of function to declare the variable path.
It's on a extern javascript file. If I use this function
in an other function to define var path, the result is an
error: path not defined. Can someone explain to me why
this doesn't work?
Apart from being quite an odd thing to want to do, and probably
considerably more simply (and reliably) achieved by other means), -
document.write - inserts HTML contents into the HTML stream (assuming
the document is not already closed at the time) and in that context
your 'var path="../images/2008/' is just text content (not script
source code (to be the latter it would have to appear in a SCRIPT
element)), and even if that text were interpreted as script content it
would only result in a syntax error as the opening double quote at the
beginning of that appears to have been intended to be a string literal
is not matched with a closing double quote.
Nov 18 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Andy Fish | last post by:
Hi, can anybody put forward a sensible argument javascript's behaviour of creating a new global variable whenever I assign to a previously undeclared variable. I can't beleive this is just for...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
3
by: Chris | last post by:
Hi, I'm really begginer in javascript. I created a form in a pop-up opened with javascript. how to recover variables of the form in the main page. Thanks for your help Chris.
6
by: Jakob Bieling | last post by:
Hi, I recently noticed that my compiler (VC++7.1) allows me to declare variables inside the expression for an if-statement, like so: if (int i = 0) { i = 1; }
6
by: Michael | last post by:
Hi. I am trying to declare variables based on DB column. I have a table with 2 columns: "varname" and "varvalue". values for example: varName: 'varPhone' varValue: '450-111-2222' During the...
2
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. ...
0
by: rpjd | last post by:
Apache2 over XP Home, PHP5, PostgreSQL8.2 If this is not the correct forum for this, it can be reposted accordingly. I have php variables/arrays that I want to display in a php webpage. What I am...
1
by: Jang | last post by:
In jslint's doc it says, "JSLint does not expect that a var will be defined in a block. This is because JavaScript blocks do not have block scope. This can have unexpected consequences. Define all...
1
by: fcfpoon | last post by:
I'm trying to develop a website with a left frame div and a main div, whereby the content of the main div changes depending on what you click on in the frame div. I'm trying to achieve this with...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...

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.