Jump to content
php.lv forumi

javascript un php


krisis007

Recommended Posts

Sveiki, man ir problēmiņa kas jums varētu likties vienkārša vai stulba, bet te nu viņa ir. Izmantojot programmu AllWebMenus 5 PRO uztaisiju mājas lapai galveno izvēlni (menu), viņa tika izstrādāta *.js formātā, bet dažās ailēs es ieliku funkciju

<?= $xxxxxx?>

un tagad es gribētu lai tam *.js failam varētu pievienot funkciju

<? require_once('../config/config.php');?>

, sakiet vai tas ir iespējas vai nav? Un ja ir tad precizējiet kā. Jau iepriekš pasaku paldies. LIELS JUMS PALDIES!

Edited by krisis007
Link to comment
Share on other sites

js failos nav prātīgi izmantot php, jo js failus browseris kešo un nekādas izmaiņas nenotiks, tas nozīmē, ka js gatavo versiju var jau nokešot servera pusē. Ja ir dinamiski jāmaina js fails, tas iesaku izmantot kādu no php templeit sistēmām.

Link to comment
Share on other sites

Rekur daļa no *.js koda

it=s2.addItemWithImages(7,8,8,"<?= $kat1?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s2.addItemWithImages(7,8,8,"<?= $kat2?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s2.addItemWithImages(7,8,8,"<?= $kat3?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);

un mana vēlme ir lai <?= $kat1?> , <?= $kat2?> un <? $kat3?> tiktu aizstātas ar to kas rakstīts config.php failā.

Link to comment
Share on other sites

Nav taadas.

 

Bet tu vari paarsaukt to JS failu par php failu. Protams, izmainot attieciigajaas vietaas arii noraades.

 

Un lai paarluuks nekeshotu (kaa jau codez piemineeja), tad celju uz JS failu noraadi, piemeeram, shaadi:

tavs_js_skripts.php?t=<?php echo time(); ?>

Link to comment
Share on other sites

Nav taadas.

 

Bet tu vari paarsaukt to JS failu par php failu. Protams, izmainot attieciigajaas vietaas arii noraades.

 

Un lai paarluuks nekeshotu (kaa jau codez piemineeja), tad celju uz JS failu noraadi, piemeeram, shaadi:

tavs_js_skripts.php?t=<?php echo time(); ?>

 

Un ja nav grūti kadas ir tās norādes un kur viņas jāliek

Link to comment
Share on other sites

ja uztaisa menu.php?menujs=1 tad vins rāda

var awmMenuName='menu'; var awmLibraryBuild=706; var awmLibraryPath='/data'; var awmImagesPath='/pic'; var awmSupported=(navigator.appName + navigator.appVersion.substring(0,1)=="Netscape5" || document.all || document.layers || navigator.userAgent.indexOf('Opera')>-1 || navigator.userAgent.indexOf('Konqueror')>-1)?1:0; if (awmAltUrl!='' && !awmSupported) window.location.replace(awmAltUrl); if (awmSupported){ var nua=navigator.userAgent,scriptNo=(nua.indexOf('Safari')>-1)?7:(nua.indexOf('Gecko')>-1)?2:((document.layers)?3:((nua.indexOf('Opera')>-1)?4:((nua.indexOf('Mac')>-1)?5:1))); var mpi=document.location,xt=""; var mpa=mpi.protocol+"//"+mpi.host; var mpi=mpi.protocol+"//"+mpi.host+mpi.pathname; if(scriptNo==1){oBC=document.all.tags("BASE");if(oBC && oBC.length) if(oBC[0].href) mpi=oBC[0].href;} while (mpi.search(/\\/)>-1) mpi=mpi.replace("\\","/"); mpi=mpi.substring(0,mpi.lastIndexOf("/")+1); var e=document.getElementsByTagName("SCRIPT"); for (var i=0;i-1) {mpi=mpi.replace("/./","/");} var awmMenuPath=mpi.substring(0,mpi.length-1); while (awmMenuPath.search("'")>-1) {awmMenuPath=awmMenuPath.replace("'","'");} document.write("

Link to comment
Share on other sites

<?
require_once('../config/config.php');

if ($_GET["menujs"]) {
?>
var awmMenuName='menu';
var awmLibraryBuild=706;
var awmLibraryPath='/data';
var awmImagesPath='/pic';
var awmSupported=(navigator.appName + navigator.appVersion.substring(0,1)=="Netscape5" || document.all || document.layers || navigator.userAgent.indexOf('Opera')>-1 || navigator.userAgent.indexOf('Konqueror')>-1)?1:0;
if (awmAltUrl!='' && !awmSupported) window.location.replace(awmAltUrl);
if (awmSupported){
var nua=navigator.userAgent,scriptNo=(nua.indexOf('Safari')>-1)?7:(nua.indexOf('Gecko')>-1)?2:((document.layers)?3:((nua.indexOf('Opera')>-1)?4:((nua.indexOf('Mac')>-1)?5:1)));
var mpi=document.location,xt="";
var mpa=mpi.protocol+"//"+mpi.host;
var mpi=mpi.protocol+"//"+mpi.host+mpi.pathname;
if(scriptNo==1){oBC=document.all.tags("BASE");if(oBC && oBC.length) if(oBC[0].href) mpi=oBC[0].href;}
while (mpi.search(/\\/)>-1) mpi=mpi.replace("\\","/");
mpi=mpi.substring(0,mpi.lastIndexOf("/")+1);
var e=document.getElementsByTagName("SCRIPT");
for (var i=0;i<e.length;i++){if (e[i].src){if (e[i].src.indexOf(awmMenuName+".js")!=-1){xt=e[i].src.split("/");if (xt[xt.length-1]==awmMenuName+".js"){xt=e[i].src.substring(0,e[i].src.length-awmMenuName.length-3);if (e[i].src.indexOf("://")!=-1){mpi=xt;}else{if(xt.substring(0,1)=="/")mpi=mpa+xt; else mpi+=xt;}}}}}
while (mpi.search(/\/\.\//)>-1) {mpi=mpi.replace("/./","/");}
var awmMenuPath=mpi.substring(0,mpi.length-1);
while (awmMenuPath.search("'")>-1) {awmMenuPath=awmMenuPath.replace("'","'");}
document.write("<script SRC='"+awmMenuPath+awmLibraryPath+"/awmlib"+scriptNo+".js'><\/SCRIPT>");
var n=null;
awmzindex=1000;
}

var awmImageName='';
var awmPosID='';
var awmSubmenusFrame='';
var awmSubmenusFrameOffset;
var awmOptimize=0;
var awmComboFix=2;
var awmUseTrs=0;
var awmSepr=["0","","",""];
function awmBuildMenu(){
if (awmSupported){
awmImagesColl=["main-header.jpg",4,32,"main-footer.jpg",4,32,"indicator.png",9,32,"main-button-tile.jpg",21,32,"main-buttonOver-tile.jpg",21,32,"main-buttonOver-left.jpg",21,32,"main-buttonOver-right.jpg",21,32,"hassubmenu.gif",7,7,"sub-button-tile.png",20,26,"sub-buttonOver-tile.png",20,26,"sub-button-left.png",34,26,"sub-buttonOver-left.png",34,26,"sub-button-right.png",34,26,"sub-buttonOver-right.png",34,26,"picresized_1213941861_tv3png.png",16,16,"3+.png",16,16,"1213943231_sport.png",17,12,"tv1000s.png",17,12,"Skeonanimation.gif",16,16];
awmCreateCSS(1,2,1,'#FFFFFF',n,n,'14px sans-serif',n,'none',0,'#000000','0px 0px 0px 0',0);
awmCreateCSS(0,2,1,'#FFFFFF',n,n,'14px sans-serif',n,'none',0,'#000000','0px 0px 0px 0',0);
awmCreateCSS(1,2,1,'#000000',n,n,'14px sans-serif',n,'none',0,'#000000','0px 0px 0px 0',0);
awmCreateCSS(0,1,0,n,n,n,n,n,'none',0,'#000000',0,0);
awmCreateCSS(1,2,1,'#FFFFFF',n,3,'11px Tahoma',n,'none',0,'#000000','0px 15px 0px 25',1);
awmCreateCSS(0,2,1,'#FFFFFF',n,4,'11px Tahoma',n,'none',0,'#000000','0px 15px 0px 25',1);
awmCreateCSS(0,1,0,n,n,n,n,n,'solid',1,'#808080',0,0);
awmCreateCSS(1,2,0,'#000000',n,8,'11px Tahoma',n,'none',0,'#000000','0px 10px 0px 35',1);
awmCreateCSS(0,2,0,'#000000',n,9,'11px Tahoma',n,'none',0,'#000000','0px 10px 0px 35',1);
awmCreateCSS(1,2,0,'#000000',n,8,'11px Tahoma',n,'none',0,'#000000','0px 10px 0px 7',1);
awmCreateCSS(0,2,0,'#000000',n,9,'11px Tahoma',n,'none',0,'#000000','0px 10px 0px 7',1);
var s0=awmCreateMenu(0,0,0,0,1,0,0,0,0,0,0,0,1,3,0,0,1,n,n,100,0,0,0,0,511,-1,1,200,200,0,0,0,"0,0");
it=s0.addItemWithImages(0,1,1,"","","","",0,0,0,3,3,3,n,n,n,"",n,n,n,n,n,0,0,0,n,n,n,n,n,n,0,0,0,0,0);
it=s0.addItemWithImages(4,5,5,"Sākums",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,"default.php",n,0,0,2,n,5,5,n,6,6,0,1,1,0,0);
it=s0.addItemWithImages(4,5,5,"TV 6",n,n,"",n,n,n,3,3,3,2,2,2,"",n,n,n,n,n,0,0,2,n,5,5,n,6,6,0,1,1,0,0);
var s1=it.addSubmenu(0,0,-1,0,0,0,0,6,0,1,0,n,n,100,0,3,0,-1,1,200,200,0,0);
it=s1.addItemWithImages(7,8,8,"Apskatīt kategoriju",n,n,"",n,n,n,3,3,3,7,7,7,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
var s2=it.addSubmenu(0,0,-1,0,0,0,0,6,0,1,0,n,n,100,0,4,0,-1,1,200,200,0,0);
it=s2.addItemWithImages(7,8,8,"<?= $kat1?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s2.addItemWithImages(7,8,8,"<?= $kat2?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s2.addItemWithImages(7,8,8,"<?= $kat3?>",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(7,8,8,"Apskatīt",n,"Apskatit","",n,n,n,3,3,3,7,7,7,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
var s2=it.addSubmenu(0,0,-1,0,0,0,0,6,0,1,0,n,n,100,0,6,0,-1,1,200,200,0,0);
it=s2.addItemWithImages(7,8,8,"Programma",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s0.addItemWithImages(4,5,5,"Aktivitātes",n,n,"",n,n,n,3,3,3,2,2,2,"",n,n,n,n,n,0,0,2,n,5,5,n,6,6,0,1,1,0,0);
var s1=it.addSubmenu(0,0,-1,0,0,0,0,6,0,1,0,n,n,100,0,1,0,-1,1,200,200,0,0);
it=s1.addItemWithImages(9,10,10,"      Foto galerija      ",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s0.addItemWithImages(4,5,5,"Kontakti",n,n,"",n,n,n,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,n,5,5,n,6,6,0,1,1,0,0);
it=s0.addItemWithImages(4,5,5,"Partneri",n,n,"",n,n,n,3,3,3,2,2,2,"",n,n,n,n,n,0,0,2,n,5,5,n,6,6,0,1,1,0,0);
var s1=it.addSubmenu(0,0,-1,0,0,0,0,6,0,1,0,n,n,100,0,5,0,-1,1,200,200,0,0);
it=s1.addItemWithImages(9,10,10,"    TV 3             ",n,n,"",14,14,14,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(9,10,10,"    TV 3 +",n,n,"",15,15,15,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(9,10,10,"    Sport",n,n,"",16,16,16,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(9,10,10,"    TV 1000",n,n,"",17,17,17,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(9,10,10,"    TB 1000",n,n,"",17,17,17,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s1.addItemWithImages(9,10,10,"    Skeon",n,n,"",18,18,18,3,3,3,n,n,n,"",n,n,n,n,n,0,0,2,10,11,11,12,13,13,1,1,1,0,0);
it=s0.addItemWithImages(2,1,1,"","","","",1,1,1,3,3,3,n,n,n,"",n,n,n,n,n,0,0,0,n,n,n,n,n,n,0,0,0,0,0);
s0.pm.buildMenu();
}}
<?
}?>

Man tas izskatas šitā , un neiet

Link to comment
Share on other sites

Bet te viss i kārtība un ja es vissu sapratu tad brouseris nevar izpildīt funkciju

<body  onload="awmShowGroup('menu-gr0',0,0,0,0);">

šī funkcija viņam būtu jāņem no tā *.js faila

P.S. Errors rādas - Object expected

Edited by krisis007
Link to comment
Share on other sites

×
×
  • Create New...