X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Running a little java script in static page (https://forum.x-cart.com/showthread.php?t=28801)

Paul H 02-12-2007 03:42 PM

Running a little java script in static page
 
Hello
I'm back into my cart again and was putting some of my old html pages into the static pages
but the little calculation chart I have won't run and I guess that there is something in xcart that prevents this so need to know if there is a way around this or how can I put a simple link in the vert menu box which holds the static page links so it just opens up a new regular page outside the centre box- I thought of putting a link within the static page but prefer not to do this.
Thanks in A

Paul

balinor 03-19-2007 09:06 AM

Re: Running a little java script in static page
 
So you want all of your static page links to open in a new window?

Paul H 03-20-2007 09:15 AM

Re: Running a little java script in static page
 
I'd like all my statics to open up in the centre panel but xcart won't allow java scripts.I even tried putting the link in the footer with some code that would open a new window without all the browser stuff and of a smaller size but this threw a smarty error. I read somewhere that it's not good website practice to have new pages opening up everywhere so trying to avoid this.Guess they are called static for a reason.

balinor 03-20-2007 09:17 AM

Re: Running a little java script in static page
 
X-Cart has no problem with JavaScript, you just need to call it correctly. By default, embedded static pages DO open in the center panel...not sure what you are trying to achieve?

Paul H 03-20-2007 10:14 AM

Re: Running a little java script in static page
 
OK
Here's what I'm trying to acheive:

I'm trying to get my webpage with javascript to open up in the centre and still have the javascript working at the end of it.

I can't do it which is why I was asking the question here.

Here is the JS:

http://www.vwspeedshop.com/pg/Engine%20Calculator.htm

balinor 03-20-2007 10:15 AM

Re: Running a little java script in static page
 
You need to put the javascript in the <head> tag, which means you need to add it to customer/home.tpl. Then when you add the rest of the content to an embedded static page, it should show fine in the main area.

PhilJ 03-20-2007 10:25 AM

Re: Running a little java script in static page
 
In General Settings, enable 'Parse Smarty tags in the content of embedded static pages'

Add this script to your static page...
Code:

{literal}
<script language="javascript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>
{/literal}

Then add a link...
Code:

<a href="http://www.vwspeedshop.com/pg/Engine%20Calculator" onclick="NewWindow(this.href,'mywin','600','600','no','center');return false" onfocus="this.blur()">Engine Calculator</a>

Should do the job :)

Paul H 03-20-2007 12:31 PM

Re: Running a little java script in static page
 
Ok
I tried that with some success.
When I click the link created by xcart in the lefthand column
it opens the centre section with another link and when clicked
produces a new window of given size but I have to have the page in a separate
folder outside of xcart-if I try putting anything in the embedded bit via admin/static pages
it causes all sorts of probs.
Now I'm going to try and add some code to the link on my footer so it opens a small simple page

Paul H 03-20-2007 01:48 PM

Re: Running a little java script in static page
 
Well thanks guys.
I pasted Phils code into the customer/home file and the link code into the link in the footer
and it now works fine.


All times are GMT -8. The time now is 01:44 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.