473,320 Members | 2,104 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,320 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
3 1474
Rik
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 ..
According to this, you echo "alert('hi');>\n echo " to the browser, and the
loose </script> would cause PHP to fail... Is this the actual code??
Can you tell me the reason and how to fix it ?


You'd better look at the source, and post that to a javascript ng.

Maybe it's just simply:

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

Then again, I don't know javascript....

Grtz,
--
Rik Wasmus
May 30 '06 #2
Carved in mystic runes upon the very living rock, the last words of
<pu*********@gmail.com> of comp.lang.php make plain:
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>";

}


If that's a copy-and-paste, you're missing a " at the end of your second
echo statement. Other than that, it works fine for me.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
May 30 '06 #3
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>";
}


FWIW, many people don't know that they can embed HTML inside PHP;
if embedded, it's easier to maintain/debug and faster to execute.
Example:
function foo()
{
?>
<script>
alert("foo");
</script>
<?php
}

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jun 4 '06 #4

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
4
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{
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.