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

IE Problem : Dynamic Javascript in PHP constructor

Hi all ,

I have a PHP class.
In the constructor method i use the following code :

constructor func .......
{
echo "<script type=\"text/javascript\">";
echo "alert('hi');
echo "</script>";
}
This works perfectly fine in Mozilla ..
But .. seems .. IE can't run this code ..

Can you tell me the reason and how to fix it ?

May 30 '06 #1
4 1198
pu*********@gmail.com wrote:
Hi all ,

I have a PHP class.
In the constructor method i use the following code :

constructor func .......
{
echo "<script type=\"text/javascript\">";
echo "alert('hi');
echo "</script>";
}
This works perfectly fine in Mozilla ..
But .. seems .. IE can't run this code ..

Can you tell me the reason and how to fix it ?


Hi

This has nothing to do with PHP.
The browser receives just HTML from a server and couldn't care less if that
is produced by PHP, VB, Perl, blue midgets, or just random noise.

So if you wonder why some piece of HTML doesn't work, look at the source of
the page first.
In your case you will find:
<script type="text/javascript">alert('hi');</script>

That should work in principle.
Maybe IE doesn't like to receive all commands on 1 line?
Maybe Javascript is disabled?
Maybe an earlier error on the page is causing this?
Hard to say.
I would start by adding \n after each echo.

Off topic: Why echo all the lines and give yourself a hard time?
This is perfectly legal in PHP and keeps the suff readable for you too:

constructor func .......
{
// just jump to HTML literal mode:
?>

<script type="text/javascript">
alert('hi');
</script>

<?php
// back in PHP
}

Regards,
Erwin Moller

May 30 '06 #2
Thanks Erwin,

But i already tried this .

May 30 '06 #3
pu*********@gmail.com wrote:
Thanks Erwin,

But i already tried this .


Tried what? <URL:http://jibbering.com/faq/>
PointedEars
--
But he had not that supreme gift of the artist, the knowledge of
when to stop.
-- Sherlock Holmes in Sir Arthur Conan Doyle's
"The Adventure of the Norwood Builder"
May 30 '06 #4
pu*********@gmail.com writes:
But i already tried this .


(Tried what? Please quote an appropriate part of what you are responding to).

Anyway, then the problem is probably somewhere else on the page. Can
you give a link to the page that is served so we can see for ourselves?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
May 30 '06 #5

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

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
2
by: festiv | last post by:
Hi there, I want to learn how the compiler is implementing the dynamic binding. where can i read about this subject (the hole process). thanks.
3
by: Craig Jurney | last post by:
Am having difficulty creating a dynamic <select> element using direct assignment to the element's option array (ie. someElement.option=new Option(someText, someValue);) that will work on Palm...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
3
by: pulkit.gaur | last post by:
Hi all , I have a PHP class. In the constructor method i use the following code : constructor func ....... { echo "<script type=\"text/javascript\">"; echo "alert('hi'); echo "</script>";
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
1
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
13
by: Jess | last post by:
Hello, I have some questions to do with dynamic binding. The example program is: #include<iostream> using namespace std; class A{
1
by: flashadow | last post by:
Who can explain. Can JsUnit test dynamic pages? A site uses Apache Tomcat for the start. A site consists of starting page in which is loaded 4 jsp pages. Functions that need testing take...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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.