Historic Castle
About This Attraction
Ljubljana Castle is a historic fortress located on Castle Hill in the heart of Slovenias capital, Ljubljana. It has a long history dating back to the 11th century, though most of its current structure was built in the 15th century. Visitors can explore various exhibitions and enjoy panoramic views of the city from the tower. The castle is accessible by foot, a funicular railway, or road, making it convenient for tourists.
Practical information includes the fact that Ljubljana Castle opening hours vary depending on the season, so its important to check ahead before visiting. Besides historical exhibits, the castle hosts cultural events and activities suitable for all ages. The site also features a café and restaurant where guests can relax after exploring. This makes it an ideal destination for both history enthusiasts and families.
Location Details
Address
Grajska planota 1, 1000 Ljubljana, Slovenia
Visitor Information
Pricing & Ratings
Ticket Prices
Adult
13 EUR
Child
9 EUR
Student
9 EUR
Senior
11 EUR
Opening Hours & Booking
Open
Days
Daily
Hours
10:00 AM - 8:00 PM
Seasonality
Varies by season
Booking
Booking Required?
No
Nearby Attractions
The Triple Bridge in Ljubljana is a unique architectural feature that connects the old town…
Learn More
Preseren Square in Ljubljana is a central point of the city and a common meeting…
Learn More
Dragon Bridge is a well-known landmark in Ljubljana, the capital of Slovenia. It was completed…
Learn More
Tivoli Park in Ljubljana is the largest park in Slovenias capital, spanning an impressive 5…
Learn More
Lake Bled is a popular tourist destination located in the town of Bled, Slovenia. The…
Learn More
Bled Castle is a historical fortress perched on a cliff overlooking Lake Bled in Slovenia.…
Learn More
Vintgar Gorge is a popular natural attraction located near Bled, Slovenia. It stretches approximately 1.6…
Learn More
The Soca River in Kobarid is a renowned destination for outdoor enthusiasts and nature lovers.…
Learn More
Piazza Unità dItalia is the largest square in Trieste, Italy, and one of the largest…
Learn More
Trieste Cathedral, also known as the Cathedral of San Giusto, is a significant historical and…
Learn More
";
}
// Initialize modal controls
const initModalControls = function() {
console.log('Initializing modal controls');
const modal = document.getElementById('attraction-modal');
const closeBtn = document.querySelector('.attraction-modal-close');
if (closeBtn) {
closeBtn.addEventListener('click', function() {
modal.style.display = 'none';
document.body.style.overflow = '';
});
}
window.addEventListener('click', function(event) {
if (event.target === modal) {
modal.style.display = 'none';
document.body.style.overflow = '';
}
});
// Make attraction cards clickable
const attractionCards = document.querySelectorAll('.attraction-card');
console.log('Found ' + attractionCards.length + ' attraction cards');
attractionCards.forEach(card => {
card.addEventListener('click', function(e) {
openModalWithCardData(this);
});
});
};
// Function to open modal with card data
const openModalWithCardData = function(card) {
// Get data from hidden div
const data = card.querySelector('.attraction-full-data');
if (!data) {
console.error('No attraction data found in card');
return;
}
const modal = document.getElementById('attraction-modal');
if (!modal) {
console.error('Modal element still not found after creation attempt');
return;
}
// Helper function to safely get element text
function getElementText(selector) {
const element = data.querySelector(selector);
return element ? element.textContent : '';
}
try {
// Basic Info
document.getElementById('attraction-modal-title').textContent = getElementText('.attraction-name');
document.getElementById('attraction-modal-type').textContent = getElementText('.attraction-type-full');
document.getElementById('attraction-modal-description').textContent = getElementText('.attraction-description-full');
// Reset all containers to hidden
['attraction-modal-hours-container', 'attraction-modal-price-container',
'attraction-modal-address-container', 'attraction-modal-image-container'].forEach(id => {
const container = document.getElementById(id);
if (container) container.style.display = 'none';
});
// Rating
const ratingText = getElementText('.attraction-rating-full');
if (ratingText) {
const ratingValue = parseFloat(ratingText);
if (!isNaN(ratingValue)) {
const ratingValueEl = document.getElementById('attraction-modal-rating-value');
const ratingFillEl = document.getElementById('attraction-modal-rating-fill');
if (ratingValueEl) ratingValueEl.textContent = ratingValue.toFixed(1) + '/10';
if (ratingFillEl) ratingFillEl.style.width = (ratingValue * 10) + '%';
}
}
// Show the modal
modal.style.display = 'block';
document.body.style.overflow = 'hidden'; // Prevent background scrolling
console.log('Modal opened successfully');
} catch (error) {
console.error('Error opening modal:', error);
}
};
// Try to create the modal
const created = createModal();
console.log('Modal created:', created);
// If not created (already exists), initialize the controls
if (!created) {
initModalControls();
}
// Also initialize distance toggle
const distanceToggle = document.getElementById('distance-unit-toggle');
if (distanceToggle) {
distanceToggle.addEventListener('change', function() {
const showKm = this.checked;
// Update toggle labels
const labels = document.querySelectorAll('.toggle-label');
if (labels.length >= 2) {
labels[0].style.opacity = showKm ? '0.5' : '1';
labels[1].style.opacity = showKm ? '1' : '0.5';
}
// Update all distance displays
document.querySelectorAll('.nearby-attraction-card').forEach(card => {
const kmEl = card.querySelector('.distance-km');
const miEl = card.querySelector('.distance-mi');
if (kmEl && miEl) {
kmEl.style.display = showKm ? 'inline' : 'none';
miEl.style.display = showKm ? 'none' : 'inline';
}
});
});
}
});