Support Forums

java and html

This is a discussion on java and html within the Templates, HTML, CSS, and Design Help forums, part of the General category; I tried using javascript in my home tpl and it also in my home page content... it just didn't work. ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 05-26-2006, 09:51 AM   #1
Member
 
lbrown13's Avatar
 
Join Date: May 2006
Posts: 80
Rep Power: 20
lbrown13 is on a distinguished road
Default java and html

I tried using javascript in my home tpl
and it also in my home page content... it just didn't work.
it said to put a script line in the head section...i put a head section
in and it removes it. Can I fix this?
I really like zman's jamestown classifieds....is there a way to drop
html and java...in without messing up the look of the site?


Thanks!
lbrown13 is offline   Reply With Quote
Old 05-26-2006, 10:05 AM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,325
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

The template files allready are html so adding additional html isnt a problem.

Javascript usually isnt a problem, but the smarty templates are compiled or in other words they are combined with the underlying php scripts and presented to the browser.

Because of this you have to explicitly let smarty know that javascript is there by telling it to not compile the javascript. This is done by placing literal tags around your javascript

{literal}
your javascript here
{/literal}

Even doing so certain javascripts can still cause problems and the best way to include them is by putting the javascript in an external file and then calling that file. example....

<script language="JavaScript" type="text/javascript" src="myjavascript.js"></script>

This has 2 benefits, it keeps the presentation (ie html) seperate from the logic and it also allows for the java script to be cached.


http://smarty.php.net/manual/en/lang...on.literal.php
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 05-26-2006, 10:19 AM   #3
Member
 
lbrown13's Avatar
 
Join Date: May 2006
Posts: 80
Rep Power: 20
lbrown13 is on a distinguished road
Default

Quote:
Originally Posted by Lhotch
The template files allready are html so adding additional html isnt a problem.

Javascript usually isnt a problem, but the smarty templates are compiled or in other words they are combined with the underlying php scripts and presented to the browser.

Because of this you have to explicitly let smarty know that javascript is there by telling it to not compile the javascript. This is done by placing literal tags around your javascript

{literal}
your javascript here
{/literal}

Even doing so certain javascripts can still cause problems and the best way to include them is by putting the javascript in an external file and then calling that file. example....

<script language="JavaScript" type="text/javascript" src="myjavascript.js"></script>

This has 2 benefits, it keeps the presentation (ie html) seperate from the logic and it also allows for the java script to be cached.


http://smarty.php.net/manual/en/lang...on.literal.php

Stupid literal tags! You have told me that already Larry... and I completely forgot!

Thanks...and you can throw something at me for forgetting!
lbrown13 is offline   Reply With Quote
Old 05-26-2006, 10:27 AM   #4
Member
 
lbrown13's Avatar
 
Join Date: May 2006
Posts: 80
Rep Power: 20
lbrown13 is on a distinguished road
Default

ok...I got it working...sorta...
It is the bookmark button like Zman uses.
it bookmarks the site like it suppose to..but when I open it from the favorites..in firefox...it opens it in a sidebar!
Any thoughts?

Larry
lbrown13 is offline   Reply With Quote
Old 05-26-2006, 10:44 AM   #5
curmudgeon
 
Join Date: Mar 2006
Posts: 5,325
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

My javascript is weak but I can take a peak. Can you post the javascript you used?
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 05-26-2006, 10:56 AM   #6
Member
 
lbrown13's Avatar
 
Join Date: May 2006
Posts: 80
Rep Power: 20
lbrown13 is on a distinguished road
Default

Quote:
Originally Posted by Lhotch
My javascript is weak but I can take a peak. Can you post the javascript you used?
Code:
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
I see that it says sidebar...but don't know what to change it to.

Thanks again Larry!

Great name by the way!
lbrown13 is offline   Reply With Quote
Old 05-26-2006, 11:30 AM   #7
curmudgeon
 
Join Date: Mar 2006
Posts: 5,325
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Unfortunatly Larry I dont think there is a way via javascript to add a bookmark that isnt in the side panel. IE has many more "features" than most other browsers which can be good or bad depending on how look at it.

If you view your bookmarks in firefox and check the properties you can uncheck the box saying to open in in the sidebar after the fact but im not sure how to do it automatically via the javascript.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 05-26-2006, 01:36 PM   #8
Member
 
lbrown13's Avatar
 
Join Date: May 2006
Posts: 80
Rep Power: 20
lbrown13 is on a distinguished road
Default

Quote:
Originally Posted by Lhotch
Unfortunatly Larry I dont think there is a way via javascript to add a bookmark that isnt in the side panel. IE has many more "features" than most other browsers which can be good or bad depending on how look at it.

If you view your bookmarks in firefox and check the properties you can uncheck the box saying to open in in the sidebar after the fact but im not sure how to do it automatically via the javascript.

Ok..Thanks. I will ask zman if he will share his bookmark.js
Thanks again Larry!



Larry
lbrown13 is offline   Reply With Quote
Old 05-26-2006, 01:48 PM   #9
curmudgeon
 
Join Date: Mar 2006
Posts: 5,325
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by lbrown13
Ok..Thanks. I will ask zman if he will share his bookmark.js
Thanks again Larry!

Larry
I dont think its a matter of your script VS his script or any script for that matter. I dont beleive the functionality exists. The javascript method....

window.external.AddFavorite

is specific to IE only and thats why its not used for the other browsers in your above javascript.

Just like with html and CSS certain versions of browsers dont support all tags. The same is true for javascript. Certain "methods" only work for certain browsers.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 05-26-2006, 01:54 PM   #10
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,493
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Here is some javascript I had on a site which seems to be very close to what you have. I believe lhotch is right.
Code:
function addbookmark(title,url) 
{
    if (window.sidebar) 
    { 
        window.sidebar.addPanel(title, url,""); 
    } 
    else if( document.all ) 
    {
        window.external.AddFavorite( url, title);
    } 
    else if( window.opera && window.print ) 
    {
        return true;
    }
}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0