Well, headfallingoff,
First, we can give you ideas on how to handle these items, but, usually we assist here in fixing coding
errors that members can not solve. We usually need to see some code and then we can help you fix the
problem errors. But, let’s discuss some of your items without code at this point…
You are using PHP code to access your mail system. To be able to use PHP for this application, you would
need to be able to tell the emails apart somehow. Most mail systems use some sort of ID that you can use
in your coding. That email would have to be used to pass from browser page to browser page. You can
just add that ID to the page you are opening and use the $_GET array to pull the data into PHP and then
retrieve the correct email.
Now, opening new pages in a tab is an option set inside the browser itself. There is an option to open it
in a new window or in a new tab. So, this might work differently inside another computer’s browser. The
Firefox vs. IE vs. Chrome should not really matter. You are just opening a new tab with an URL that has a
ID in it for an email. Same code for Firefox or IE… You just set the link to “target blank” which forces the
url to open in a new tab BUT, you can not open two URL’s using one link unless you use something like JS.
Here is a simple way to open two different pages at the same time. It basically just makes the link call a
small JQuery routine that opens two pages. Should work…
HTML:
[php]
Click Here To Open Two Pages
[/php]
Javascript/JQuery
[php]
$(‘a.open2pages’).click(function(e) {
e.preventDefault();
window.open(‘http://mysite.com/readmail.php’);
window.open(‘http://mysite.com/ringbell.php’);
});
[/php]
Although, why don’t you ring the bell alert when you load the email into a new tab?
Passing PHP data into JS code is easy. But, you must understand how they both work. First, PHP is on
the server. It is SERVER-SIDE only code. You will never be able to read PHP code by looking at what is on
a page in your browser. PHP does not exist there. All PHP code is processed on the server and it’s outputs
along with the HTML code are combined then sent to the browser. The JS code along with JQuery is inside
the browser and runs CLIENT-SIDE only. The browser takes the server’s combined output and adds in the
CSS styling and then runs any Javascript. So, to put data from PHP into a Javascript, you just remove the
old data and have PHP place the data where it is needed. Let’s take my example above for displaying a URL
in a new window. ( " window.open(‘http://mysite.com/readmail.php’); " ) If you wanted to use this to
display a email you can add to the URL an ID number for the email to be displayed. Just change it to show
the ID. Something like: window.open(‘http://mysite.com/readmail.php?email_id=3’); for the ID of 3 !
In the readmail.php file, you would grab this ID number like: $email_id=$_GET[“email_id”];
Now, that would allow you to pass the email ID as needed to the new page. You just need to figure out
how to create the URL inside the Javascript routine. To do this, you would need to simply replace the ID as
it is now hard-coded as #3 to a variable which of course you would load from your database with the right
ID for the link you are creating… Something like this might work:
[php]
<?PHP
// Do something here to get the ID you want inside the link, right now I will just hard-code it to 13...
$email_id = 13;
?>
$(‘a.open2pages’).click(function(e) {
e.preventDefault();
window.open(‘http://mysite.com/readmail.php?email_id=<?PHP echo $email_id; ?>’);
window.open(‘http://mysite.com/ringbell.php’);
});
[/php]
As you can see, it uses the PHP value of the email_id that you got from the database (in this example 13)
and then places it into the Javascript code. Remember, the PHP does not exist after it gets to the browser,
so the results of that link would be
window.open(‘http://mysite.com/readmail.php?email_id=13’);
Which is what you want. Then, when the user clicks on that link, the PHP code inside the second window
would read the ID number and open that email for displaying.
As far as the sound goes, you can just have the email display page play the sound upon loading using a
JS script. Or, you can use the second URL version as you indicated and have that second page play the
sound and then close the page so it goes away… Depends on the numbers of emails you get each hour.
Well, not really sure how helpful that is, but, I think it should help you get started. Once you get it coded
up, if you have problems show us the code areas that you are having issues with and we can help…