• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1519
  • Last Modified:

What Is Your Opinion of a PHP to JavaScript Converter?

Hi EE,

Not being very technical (quite an understatement) and only being marginally familiar with JavaScript, I would like to get your opinion on something:

I want to run a PHP script on my website but the company hosting it does not allow PHP to be loaded. Please don't suggest changing hosting companies, because that is a long and separate discussion.

For sake of argument, let's assume that I cannot change companies. I was doing some searching on Google for "PHP to JavaScript Converter" and ran across the following:

http://www.harmony-framework.com/

Can you please supply a an opinion on what you think of the above approach; the PHP to JavaScript converter concept as a whole; and in the converter that you have found which works the best?

Your help in this matter is greatly appreciated.
0
photoman11
Asked:
photoman11
  • 4
  • 3
  • 2
2 Solutions
 
HonorGodCommented:
In general, any converter is only going to be able to convert literally from language A to language B.

In every instance that I have used, it was really, really helpful for me to understand both languages very well, so that I could use the translated code as a starting point.

From there, I would look for opportunities to take advantage of data structures in each language, and frequently, I found it best to rewrite, instead of using the translated code.


0
 
joep1978Commented:
JavaScript won't be able to connect to a MySQL database so immediately one of the best things about PHP goes out the window.  None of the PHP libraries would be available either so really it's not a great deal more than a syntax convertor.  Plus normally PHP code is hidden from the end-user - with Javascript it wouldn't be so there might be security implications depending on what youre trying to do.

How feasible using Javascript is kinda depends on what you need your script to do?
0
 
photoman11Author Commented:
As far as me having knowledge of one language, let alone two, I think I would have more luck teaching pigs to fly.

On a more practical note, here is the sales page for the product that I am talking about which produces a PHP script: http://www.exitsplash.com/

I provided the link here because this would give you a much better idea of what I am looking to do than I can possibly explain. Exit Splash could come off as simply an elaborate POP-UP page creator, however when combined with all of his templates and approaches, etc. my understanding (although not complete, I will admit) is that it is far more than that.

I think part of the reason why his package is so powerful is that it includes the integration of some of the bonuses he is offering, into the main product.

Anyway, that's the gist of it, so if you are aware of any Java scripts that can produce things like this without being blocked by pop-up blockers, please let me know. I would be extremely interested!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
joep1978Commented:
Here's the code from his page.  It should work if you copy and paste it in - it's just Javascript generated by PHP


var exitsplashalertmessage = '***************************************\n\n         > > > W A I T < < <\n\n     CLICK THE ***CANCEL*** BUTTON\n    on the NEXT Window for Something\n             VERY Special!\n\n***************************************';
var exitsplashmessage = '***************************************\n\n W A I T   B E F O R E   Y O U   G O !\n\n  CLICK THE *CANCEL* BUTTON RIGHT NOW\n     TO STAY ON THE CURRENT PAGE.\n\n I HAVE SOMETHING VERY SPECIAL FOR YOU!\n\n***************************************';
var exitsplashpage = 'http://www.exitsplash.com/exit/exit.php?hop=ehotitems';
 
function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); }  func(); }}}
function addClickEvent(a,i,func) { if (typeof a[i].onclick != 'function') { a[i].onclick = func; } }
var theDiv = '<div id="ExitSplashDiv"  style="display:block; width:100%; height:100%; position:absolute; background:#FFFFFF; margin-top:0px; margin-left:0px;" align="center">';
theDiv = theDiv + '<div id="ExitCancelButtonImageDiv" style="background: #FFFFFF; width: 100%;" align="left"><img src="http://exitsplash.s3.amazonaws.com/files/exitimpactimage.gif?exit49f4f3a2c2316" border="0"></div>';
theDiv = theDiv + '<div onmouseover="this.style.background=\'#FFFFFF\'; document.getElementById(\'exitsplashlink\').style.color=\'#0000FF\'" onmouseout="this.style.background=\'#3399cc\'; document.getElementById(\'exitsplashlink\').style.color=\'#FFFFFF\'" style="padding-top:0px; padding-left:0px; margin-top:0px; margin-left:0px; background:#3399cc; width: 100%; height: 22px; text-align:right;"><span style="font-family:tahoma; font-size:12px; font-weight:bold; color:#3399cc">Increases Website Response by up to 325% in 3 days! CLICK HERE ==&gt;</span>&nbsp;&nbsp;<a href="http://www.exitsplash.com" target="_blank" style="text-decoration:none;"><span id="exitsplashlink" style="font-family:tahoma; font-size:12px; font-weight:bold; color:#FFFFFF">Powered by ExitSplash</span></a>&nbsp;&nbsp;&nbsp;</div>';
theDiv = theDiv + '<div id="exitsplashimpactaudio"><embed wmode="transparent" src="http://exitsplash.s3.amazonaws.com/player.swf?url=http://exitsplash.s3.amazonaws.com/files/exitsplash.mp3&mode=play&autostart=true&exit49f4f3a2c2316" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="1" height="1"></embed></div>';
theDiv = theDiv + '<iframe src="'+exitsplashpage+'" width="100%" height="100%" align="middle" frameborder="0"></iframe>';
theDiv = theDiv + '</div>';
theBody = document.body; if (!theBody) {theBody = document.getElementById("body"); if (!theBody) {theBody = document.getElementsByTagName("body")[0];}}
var PreventExitSplash = false;
function DisplayExitSplash(){ if(PreventExitSplash == false){ window.scrollTo(0,0);  PreventExitSplash=true; divtag = document.createElement("div"); divtag.setAttribute("id","ExitSplashMainOuterLayer"); divtag.style.position="absolute"; divtag.style.width="100%"; divtag.style.height="100%"; divtag.style.zIndex="99"; divtag.style.left="0px"; divtag.style.top="0px"; divtag.innerHTML=theDiv; theBody.innerHTML=""; theBody.topMargin="0px"; theBody.rightMargin="0px"; theBody.bottomMargin="0px"; theBody.leftMargin="0px"; theBody.style.overflow="hidden"; theBody.appendChild(divtag); return exitsplashmessage; } }
var a = document.getElementsByTagName('A'); for (var i = 0; i < a.length; i++) { if(a[i].target !== '_blank') {addClickEvent(a,i, function(){ PreventExitSplash=true; });} else{addClickEvent(a,i, function(){ PreventExitSplash=false;});}}disablelinksfunc = function(){var a = document.getElementsByTagName('A'); for (var i = 0; i < a.length; i++) { if(a[i].target !== '_blank') {addClickEvent(a,i, function(){ PreventExitSplash=true; });} else{addClickEvent(a,i, function(){ PreventExitSplash=false;});}}}
hideexitcancelbuttonimage = function(){ document.getElementById('ExitCancelButtonImageDiv').style.display='none'; }
addLoadEvent(disablelinksfunc);
disableformsfunc = function(){ var f = document.getElementsByTagName('FORM'); for (var i=0;i<f.length;i++){ if (!f[i].onclick){ f[i].onclick=function(){ PreventExitSplash=true; } }else if (!f[i].onsubmit){ f[i].onsubmit=function(){ PreventExitSplash=true; }}}}
addLoadEvent(disableformsfunc);
window.onbeforeunload = DisplayExitSplash;

Open in new window

0
 
photoman11Author Commented:
Joep,

Well, I inserted the other could end to one of my test pages and the result was not terribly good. I'm attaching a code snippet with some of what displayed on the page.

I don't know enough about this to know whether I am supposed to do something to the code before inserting it in my page or not so that could cause the issue. Like I said, this is as foreign to me as teaching a lizard to dance.
 var exitsplashalertmessage = '***************************************\n\n > > > W A I T < < <\n\n CLICK THE ***CANCEL*** BUTTON\n on the NEXT Window for Something\n VERY Special!\n\n***************************************';var exitsplashmessage = '***************************************\n\n W A I T B E F O R E Y O U G O !\n\n CLICK THE *CANCEL* BUTTON RIGHT NOW\n TO STAY ON THE CURRENT PAGE.\n\n I HAVE SOMETHING VERY SPECIAL FOR YOU!\n\n***************************************';var exitsplashpage = 'http://www.exitsplash.com/exit/exit.php?hop=ehotitems';
 
function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); }}}function addClickEvent(a,i,func) { if (typeof a[i].onclick != 'function') { a[i].onclick = func; } }var theDiv = '
';theDiv = theDiv + '
';theDiv = theDiv + '
Increases Website Response by up to 325% in 3 days! CLICK HERE ==> Powered by ExitSplash
';theDiv = theDiv + '
';theDiv = theDiv + '
 
(in addition I received some messages like these:)
 
Error: Execution of this script not permitted

Open in new window

0
 
joep1978Commented:
Sorry, I had a play with this code and it seemed to work but it's a horrible, spammy script and I kept getting tons of popups opening so I hope you understand I don't really want to work too much on it :)

The code listed is the actual script from ExitSplash and it should work with no need for PHP.  You will need to modify the first three lines to fit your site and then paste it into a Javascript file.  You should then be able to include this Javascript file on a HTML file on your server
0
 
photoman11Author Commented:
Joep,

I completely understand. Thanks for your effort. I'm clueless as to what would need to be done, so it's probably best to let this die quietly for now.
0
 
photoman11Author Commented:
thanks for everything, guys.
0
 
HonorGodCommented:
Thanks for the assist and the points.

Good luck & have a great day
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now