WebSite X5Help Center

 
Luigi Dell'aquila
Luigi Dell'aquila
User

Accesso all'iframe solo per le pagine del sito  it

Author: Luigi Dell'aquila
Visited 582, Followers 2, Shared 0  

Ciao a tutti.
Ho la pagina "leggere.html" con un iframe dove poter visualizzare altre pagine html da me create, questo sia per le pagine temporanee (successivamente da cancellare) che per non aumentare le pagine del sito.
Funziona tutto però non so come fare per dare l'accesso all'iframe di leggere.html solo alle pagine che si trovino all'interno del mio spazio web. Questo per evitare che altri possano far visualizzare le loro pagine nel mio sito.
Grazie

La pagina di prova è questa http://www.luigidellaquila.altervista.org/prove_varie/leggere.html
Per visualizzare prova.html (che si trova nella sottocartella "doc") basta scrivere
http://www.luigidellaquila.altervista.org/prove_varie/doc/prova.html" target="_blank" rel="noopener">http://www.luigidellaquila.altervista.org/prove_varie/leggere.html#http://www.luigidellaquila.altervista.org/prove_varie/doc/prova.html

In "leggere.html" ho inserito quesi codici:

Prima della chiusura del tag head
<!-- "leggere = visualizza" -->
<script>
$("document").ready(function () {
var h = window.location.hash.slice(1);
if (h != '') {
$('#leggere').attr('src', h);
}
});
</script>

Nell'oggetto HTML:
<iframe id="leggere" style="width:100%; height:100%; overflow: hidden; border: none;" src="http://www.luigidellaquila.altervista.org/prove_varie/doc/bianco.html"></iframe>

Posted on the
12 ANSWERS - 4 USEFUL - 1 CORRECT
Claudio D.
Claudio D.
Moderator
Best User of the month IT

se intendi che non vuoi che altri inseriscano le tue pagine tramite iframe nel loro sito , e sei sotto Linux

puoi bloccarlo , aggiungendo queste istruzioni nell'htaccess , guarda se fa al caso tuo...

<IfModule mod_headers.c>

Headerset X-Frame-Options"SAMEORIGIN"

</IfModule>

Read more
Posted on the from Claudio D.
Claudio D.
Claudio D.
Moderator
Best User of the month IT

sinceramente non ho capito , come potrebbero inserire loro pagine nel tuo sito ? 

Read more
Posted on the from Claudio D.
Claudio D.
Claudio D.
Moderator
Best User of the month IT

ah ok ... ho capito...

passi la variabile del sito tramite url... 

Read more
Posted on the from Claudio D.
Luigi Dell'aquila
Luigi Dell'aquila
User
Author

Esatto

Read more
Posted on the from Luigi Dell'aquila
Claudio D.
Claudio D.
Moderator
Best User of the month IT

...premettendo che non sono sicuro che sia corretto e pure di non aver scritto delle MEGA  cavolate... prova questo: 

<script>
$("document").ready(function () {
var h = window.location.hash.slice(1);
if (h != '' && h.substring(0, 38) === 'http://luigidellaquila.altervista.org/') {
$('#leggere').attr('src', h);
}
});
</script>

(altrimenti attendi KolAsimwink; che è lui l'esperto di queste cose) 

Read more
Posted on the from Claudio D.
Claudio D.
Claudio D.
Moderator
Best User of the month IT

io l'ho provato su di un mio sito e funziona...

ho visto che hai messo l'indirizzo col www , in quel caso la stringa non è di 38 caratteri ma di 42

(noto che va ricaricata la pagina... forse è da temporizzare... ) altro non ti so dire...  oltre non vado ...

<script>
$("document").ready(function () {
var h = window.location.hash.slice(1);
if (h != '' && h.substring(0, 42) === 'http://www.luigidellaquila.altervista.org/') {
$('#leggere').attr('src', h);
}
});
</script>

Read more
Posted on the from Claudio D.
Claudio D.
Claudio D.
Moderator
Best User of the month IT

ummm, prova anche così...

<script>
window.onhashchange = function() {
var h = window.location.hash.slice(1);
if (h != '' && h.substring(0, 42) === 'http://www.luigidellaquila.altervista.org/') {
$('#leggere').attr('src', h);
}
}</script>

__

ora mi scollego, spero che quando tornerò nei prossimi giorni , avrai risolto in un modo o nell'altro... 

Read more
Posted on the from Claudio D.
Luigi Dell'aquila
Luigi Dell'aquila
User
Author

Il primo script funziona (poi proverò anche il secondo)

Il problema era che se nello script inserisci www anche la variabile del sito da passare tramite url deve contenere www.

Grazie

Read more
Posted on the from Luigi Dell'aquila